William Andy Hainline
William Andy Hainline

Reputation: 31

Mail Rule to Run Applescript Not Working?

Question for my fellow AppleScripters. I have the following script which runs just fine if you run it in AppleScript Editor or Script Debugger, but that won't run at all if you try to run it from a Mail rule. The script is correctly placed in ~/Library/Application Scripts/com.apple.mail, and shows up in the "Run AppleScript" menu in the Mail rule, but simply refuses to work when new mail arrives.

on perform_mail_action(info)
  tell application "Mail"
set theMessages to |SelectedMessages| of info
repeat with thisMessage in theMessages
set AppleScript's text item delimiters to {""}
set thisSender to sender of thisMessage as string
set quotepos to offset of "\"" in thisSender
  if (quotepos is not 0) then
    set thisSender to (text items (quotepos + 1) through -1) ¬
      of thisSender as string
    set quotepos to offset of "\"" in thisSender
    if (quotepos is not 0) then
      set thisSender to (text items 1 through (quotepos - 1)) ¬
        of thisSender as string
    end if
  else
    set atpos to offset of "@" in thisSender
    if (atpos is not 0) then
      set thisSender to (text items 1 through (atpos - 1)) ¬
        of thisSender as string
    end if
    set brkpos to offset of "<" in thisSender
    if (brkpos is not 0) then
      set thisSender to (text items (brkpos + 1) through -1) ¬
        of thisSender as string
      end if
      end if
      tell application "Finder" to say "Mail from " & thisSender
    end repeat
  end tell
end perform_mail_action

Any ideas?

Upvotes: 0

Views: 1005

Answers (1)

William Andy Hainline
William Andy Hainline

Reputation: 31

Thanks for the feedback everyone, but I figured out the problem. It wasn't anything to do with the script at all . . . it was that I had Satimage.osax installed in my scripting additions folder, and since it's not fully ML compatible yet, it messed everything up. Once I uninstalled it, all my folder actions started working great!

Thanks!

--Andy H.

Upvotes: 0

Related Questions