Applescript to delete promotional emails after 30 days

KKG

Joined
Apr 10, 2022
Messages
2
Reaction score
0
I want an AppleScript that will move emails from the Inbox into the Archive if they are held in the "Promotional Emails" folder AND are older than 30 days. However, I do not want it to move any emails that might be in the "Promotional Emails" folder but that are also in the "Receipts/Invoices" Smart mailbox.

So I set up a rule ("To_Archive" for Apple Mail to search for all emails older than 30 days and then run an AppleScript. However, it is not working. Would you please help me write my first script. Thank you for any help!

on perform mail action with messages these_messages for rule To_Archive
tell application "Mail"
if this_message is in mailbox "Inbox"
And if this_message is in mailbox "Promotional Emails"
And if this_message is NOT in mailbox "Receipts/Invoices"

then
move this_message from mailbox "Inbox" to mailbox "Archive"
end if
end tell
end perform mail action with messages
end using terms from```
 
Joined
Jan 25, 2017
Messages
1,266
Reaction score
100
When you say it is not working, do you get any errors, or is the result something other than what you intended?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top