Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question
    
Version numbers of Mac OS X and Mail.app would be helpful –  fanaugen Mar 7 '12 at 11:46
    
As would knowing if you're using IMAP or POP. –  james.garriss Mar 7 '12 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 '13 at 4:21
add comment

2 Answers 2

up vote 0 down vote accepted

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

share|improve this answer
    
This seems like an idea. –  revolver Mar 7 '12 at 12:47
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.