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)

Posted on May 16, 2012 10:05 AM

Reply
7 replies

May 17, 2012 3:50 AM in response to red_menace

I must be doing something wrong. I created a rule that should filter out 1 (one) message from my Inbox based on the Subject and run Sample Rule Action Script in order to test it.


Test result:

1. The message "This AppleScript is intended to be used as an ..." was displayed as expected.

2. All mail messages from Inbox were moved to a subfolder of another mail account. I was quite surprised. Any idea what is going on?


Thanks

Andrej

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Mail Inbox Rule, Apple Script and Fantastical

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.