How to automatically archive inbox mail messages after X days?

I am setting up Mail on a new iMac (running Ventura) for a family member. The family member is notorious for not cleaning out their Inbox. I want to set it up so that messages in the Inbox are automatically moved to the Archive folder after a set number of days.


I can set up a Rule that archives messages after X days, but since Rules are only applied automatically when the message first comes in, this archiving only works if the user manually runs the Rule every so often. Which my user won't remember to do. So for this use case the rule really needs to happen in the background, set up once and forget.


Any ideas/thoughts/feedback? Thanks in advance!

iMac (24-inch, M1, 2021, 2 ports)

Posted on Dec 26, 2022 8:44 AM

Reply
3 replies

Dec 27, 2022 8:59 PM in response to pyzowski

Thank you for the response. I tried Automator but it doesn't appear to have the ability to select all messages in a given mailbox.

Sure you can.

Get Specified Mail Items--You can choose the desired Inbox from the account(s).

You can then Filter Mail Items using Date Received is not in the last X days/weeks/months/years

  • However, that filter actually grabs messages received today, and there isn't a way to fix that.

Then, you would have to move them with an AppleScript Action.

on run {input, parameters}
	
	tell application "Mail"
		repeat with aMessage in input
			move aMessage to mailbox "Archive"
		end repeat
	end tell
end run


I meant for you to use an AppleScript action to run your Rule. Looking at it, I don't know if that is possible, either.


There is likely a way to gather all of the messages within the AppleScript action, but that will take some more time to figure out. Maybe someone else can provide the code needed.

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.

How to automatically archive inbox mail messages after X days?

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