views:

114

answers:

2

In Apple's Mail application, one can specify that an AppleScript script be run when a rule matches a message. However, when I write a script to take advantage of this ability, the script is passed the message previous to the new one in the list (or maybe the currently selected message - not sure). Searching around, I see other folks experiencing the same issue, such as here:

http://www.cupcakewithsprinkles.com/growl-notifications-for-apple-mail-on-mac-os-x-snow-leopard-10-6/

I'll file this as a bug with Apple, but in the mean time, does anyone have a workaround?

If you'd like to see this problem for yourself, just set up the sample script bundled with Snow Leopard. You'll find it at /Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt.

A: 

I have the same issue. I noticed that it only occurs on my MS Exchange account. Other accounts work fine. I gave up and put together a nasty kludge...

I created a rule where the email gets flagged and moved to a special mail folder. Then, I have an Automater Workflow triggered from iCal that finds the flagged emails and passes them to my Applescript.

I'd love to hear about any less kludgy solutions.

Mike

MikeRyan
A: 

Count me in. Same problem here and no valid workaround yet. Everything works fine, once the Mail is in your inbox and you trigger your rules manually. It seems that the rule / the script is being executed before the message actually comes to your inbox. You can verify this by adding

set theSubject to subject of theMessage
display dialog theSubject

to your script. The Mail is not in the inbox when the dialog appears.

Stefan