Reputation: 3126
I have an Applescript
that performs a lookup when a new mail lands in my Mail
inbox to check whether I have blacklisted the e-mail's domain or not.
If the e-mail domain is blacklisted, the script deletes the mail by doing so:
tell application "Mail"
delete blackListedMailMessage
end tell
Pretty straightforward. My e-mails are properly filtered according to this blacklist of mine and moved to my trash mailbox, as I expect them to be.
The problem comes when I click the "Get messages" button in Mail: Mail retrieves the deleted messages from the server and put them back in my inbox. It seems the deletion doesn't propagate to the server. If I manually select the e-mail in Mail.app and hit delete, this does not happen.
I'm pretty newb with Applescript, so I'm not sure what's all going on. My guesses are either the Mail.app's Applescript implementation is janky or it's iCloud. It could be both...
Upvotes: 0
Views: 521
Reputation: 3126
Okay, so I'll answer my own question...
It seems that Apple's implementation of Mail.app's Applescript delete
is bugged.
Instead, use:
tell application "Mail"
move aMessage to trash mailbox
end tell
Otherwise, it will not propagate to the server if using iCloud.
Upvotes: 0