0

I'm using the following script with a Mail.app rule.

It seems that on my computer the code isn't being executed after moving the message to the Trash mailbox. (adayzdone below reports it works for him).

How can I identify the reason for this and solve it?

using terms from application "Mail"
    on perform mail action with messages theMessages
        repeat with eachMessage in theMessages
            set theText to content of eachMessage

            --
            -- ... here happens some processing
            --

            -- this works:
            move eachMessage to mailbox "Trash"

            -- but this doesn't:
            display dialog "reached this point"

            -- i.e. additional code I'm adding here isn't executed...
        end repeat
    end perform mail action with messages
end using terms from
GJ.
  • 5,226
  • 13
  • 59
  • 82
  • 1
    There is a related sounding issue discussed [over here](http://stackoverflow.com/q/9243701/990363). Do you happen to have several accounts configured in Mail.app? – kopischke Feb 27 '12 at 00:17
  • Try wrapping the `move eachMessage...` line in a `try...on error` block. You can log the error message to the Console using `do shell script "logger -t 'Your script name' " & whateverTextYouLike`. – Niko Nyman Sep 07 '12 at 21:39

1 Answers1

0

Calling it with a rule from Mail, this script works for me. Are you sure the message is reaching the inbox and not getting caught in a filter such as "skip inbox" from gmail?

using terms from application "Mail"
on perform mail action with messages theMessages
    repeat with eachMessage in theMessages
        set theText to content of eachMessage
        move eachMessage to mailbox "Trash"
        display dialog "reached this point"
        beep 2
    end repeat
end perform mail action with messages
end using terms from
adayzdone
  • 11,120
  • 2
  • 20
  • 37
  • Yes, I'm sure. The processing part is successful and I can see that the message gets moved from the inbox to the trash as a result of this rule. But the dialog still isn't displayed for me.. – GJ. Feb 14 '12 at 08:51
  • By the way, if I add a "display dialog" one line *before* the "move to Trash", the dialog does get displayed. – GJ. Feb 14 '12 at 08:52
  • 1
    On my computer, I get the dialog and the beep2. Not sure what is going on. – adayzdone Feb 14 '12 at 13:16