4

Is there a way to limit Mail to keep only the last 50 emails and delete the older ones? I am using gmail, and most of the stuff are kept there, I do not need to have everything downloaded to the Mail client. Trying to save some HDD space, as I used to have a few gigs of mail stored in /library/mail

Using OS X Lion.

Thanks.

3
  • Version numbers of Mac OS X and Mail.app would be helpful
    – fanaugen
    Mar 7, 2012 at 11:46
  • As would knowing if you're using IMAP or POP. Mar 7, 2012 at 11:52
  • I am hoping to find a solution also that allows me to set a mailbox behaviour to only keep the latest 5 emails -- is there a applescript designed for this? I am not fluent yet with how to create one.
    – user45886
    Mar 24, 2013 at 4:21

2 Answers 2

0

Since Mail does not have a predefined filter (in Smart Mailboxes) to get the 50 last received messages, I can imagine you could achieve something like this in an AppleScript.

The AppleScript should:

  1. get every message in Inbox
  2. sort the list by date
  3. select all but the most recent 50 ones
  4. delete selected

Then, create a Mail rule that will be triggered whenever a new email arrives (e.g. you could trigger it on the condition that Recipient contains an "@" or that Sender is not empty), and have the rule execute your AppleScript.

To get you started on how to write an AppleScript that processes Mail messages, see the script you can find in: /Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt

1
  • This seems like an idea.
    – revolver
    Mar 7, 2012 at 12:47
1

Mail can do something sorta like what you want.

  1. Mail > Preferences
  2. Accounts tab
  3. Mailbox Behaviors tab
  4. Trash section

On the line that says "Permanently erase deleted messages when", you can select one month old or one week or even one day. That will help get rid of old email and save you some space.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .