I am trying to create a script so that I can apply my mail sorting rules with the click of a button because they are reset every time I log onto a university computer.
So far I have figured out how to create a new rule and define its properties but cannot figure out how define the folder where the emails will be sent.
How do I define where the message will be sent?
When I type the name of the mailbox I want the message to go to, I get an error saying "Mail got an error: Can’t get mailbox “XXXXX”. If I type the name of a mailbox that is “on my mac” the script runs fine but doesn’t change the property in the rule. I am trying to create a rule that moves messages to an IMAP mailbox.
tell application "Mail"
set new_rule to make new rule at end of rules with properties {name:"New Rule", all conditions must be met:true, move message:mailbox "XXXXX"}
tell new_rule
make new rule condition at end of rule conditions with properties {rule type:from header, qualifier:equal to value, expression:"sender@domain.dom"}
make new rule condition at end of rule conditions with properties {rule type:subject header, qualifier:does contain value, expression:"XXXXX"}
end tell
end tell