I looked and looked but couldn’t find an answer to this seemingly simple question (I’m also new to AppleScript). Basically, I just want a script that sets up a Rule and moves messages to mailbox “Foo” (a Mailbox in my IMAP account). Here’s what I have:
tell application "Mail"
set newRule to make new rule at end of rules with properties {name:"Foo Internal", enabled:true}
tell newRule
make new rule condition at end of rule conditions with properties {rule type:any recipient, expression:"internal_foo@foo.com", qualifier:does contain value}
set move message to mailbox "Foo"
end tell
end tell
I’ve tried various combinations of this line…
set move message to mailbox "Foo"
…including specifying the IMAP account, setting it to a variable, and so on. I’m not a programmer but I really want to script these rules cause I setup rules all the time at my job. Any help?
Your script fails because of two things:
should move messageproperty of the rule to true, which is needed for amove messageaction to actually “stick”;accountand theapplicationcontext, as you are inside atellblock targeting the rule, not Mail.The following code:
will work in Mail 5.2 (stock as of OS X 10.7.4).