View Single Post
Hi, all. Could someone verify something for me so I know I'm not going crazy?

I've written an applescript to process messages from and create a project & actions based on the mail content. The script is called from a mail rule.

However, Mail only sends Omnifocus the expected message if I apply the rule manually. If a new mail item automatically triggers the rule, Mail sends along the next most recent item in my inbox (in other words - the message that came in BEFORE the message that's actually triggering the rule).

Is this a bug or did I mess up the script? Here's the basic loop that I use in my script:

on perform_mail_action(theData)
	tell application "Mail"
		set theSelectedMessages to |SelectedMessages| of theData
		set theRule to |Rule| of theData
		repeat with a from 1 to count theSelectedMessages
			set thesubject to subject of item a of theSelectedMessages
			display dialog thesubject
		end repeat
	end tell
end perform_mail_action
Thanks for your help!