Mail Inbox Rule, Apple Script and Fantastical
I have a script that sends the contents of an e-mail to Fantastical. It works just fine if the target mail is selected:
tell application "Mail"
set theSelection to selection
set theMessage to item 1 of theSelection
content of theMessage
set theContent to content of theMessage
end tell
tell application "Fantastical"
parse sentencetheContent
delay 0.3
tell application "System Events"
keystrokereturnusingcommand down--CMD+Enter
delay 2
key code 53 --ESC
end tell
end tell
I created a Mail Rule that should invoke this script when any mail with Subject "NewCalEvent" comes into Mailbox. The code above doesn't work as it captures content of the currently selected mail and not the one Mail Rule is handling. How should I rewrite it to make it work properly?
Thanks
Andrej
Mac OS X (10.7.3)