Automated archiving in Mail.app
I’ve had three emails in as many days from people wondering how to set up automated archiving in Mail.app, so that messages older than a specific date are moved out of the app and into a separate folder.
Although some other email clients do this (I have a vague memory that Outlook used to ask me about this from time to time), Mail doesn’t.
The only solution I could think of revolved around creating a repeating event in iCal, say once a month, and setting it to run the Archive script from Andreas Amann’s Mail scripts
which can export messages in standard mbox format.
But that’s not very automated. You still need to select the mailboxes to export and other bits and pieces.
I asked Andreas Amann
who is gobsmackingly clever with AppleScript why this isn’t easier to achieve. He tells me:
The problem is that AppleScript Studio applications themselves are not scriptable so they don’t lend themselves to be run without user interaction. Since my archive script needs the user to select which mailboxes to archive as well as some options for the archive, this won’t work.
Another solution would be to create a rule and then apply that to selected message. However, since you can’t run rules via AppleScript either, this won’t work in an automated, non-interactive way either.
I guess people will have to look at some of the commercial offerings for this (I don’t know whether they support automated or timed archiving though…)
Any ideas? (Non-commercial solutions preferred)
Tags: Apple Mail, applescript, archiving, automated, backup, export, mail.app, rulesRelated posts

November 23rd, 2006 at 1:40 am
Why should I archive?
I just checked and I have 10 years or email (Aug 1996) and over 58,000 emails in my Inboxes.
Why Archive at all?
BZ
November 23rd, 2006 at 1:53 am
BZ: That’s fine with POP-servers, because your mail is locally stored on your PC, downloading each time from your POP-server.
However, mails on IMAP-servers stay on that server, so eventually you will reach your storage limit. So, it would be nice if somehow all mails older than 3 months would be automatically downloaded from the IMAP-server to a local mail folder on your PC.
November 23rd, 2006 at 2:40 am
BZ you bring an entire new meaning to the “Unified” inbox I have seen discussed here.
But seriously I would like to know the answer to your questions as well.
Speed I would imagine is the main reason but I could be wrong.
November 23rd, 2006 at 3:22 am
Sorry to get all UNIXy, but why not use
cron,find, andmv?Findhas the ability to distinguish when a file was created and act upon it, and Mail.app stores each message as a separate .emlx file.Schedule something like:
with
crontab -e, and you have instant archiving of anything older than 30 days. (Standard backup disclaimers apply.)I’m with BZ, though — why do people want to do this? It’s easier to drop everything into a single folder and use Smart Folders/Spotlight to find what you’re looking for.
November 23rd, 2006 at 3:45 am
Archiving email could speed up Mail searches and act as a mail backup solution.
I once used eMA, eMessage Archiver, but this solution seems to be dead.
http://homepage.mac.com/thinkagain/Mac/eMA/
While you’re at it, harken back a year or so to one of your own previous discussions on Mail backup. Some Mail backup apps offer a feature to delete backuped mail, thus functioning as an archiver.
http://www.hawkwings.net/2005/09/26/backing-up-apple-mail/
November 23rd, 2006 at 4:27 am
Here’s what I do. I create a smart folder that collates everything that I want to archive.
Every three-four months I go there, select all (apple-A) then go File > Save As.
This saves all the messages as rich text, which is easily searchable and mungable.
It won’t work for those that need to be able to reply several years down the track, or if you use your inbox as photo storage, but it does give you a nice text record of everything that you’ll always be able to open.
November 23rd, 2006 at 4:31 am
Speed might be an issue, but really, I always worry that once something gets archived, it isn’t really usable anymore, more apt to be lost, not backed up.
Why shouldn’t a modern Mac (24″ iMac) be able to handle that many email messages?
BZ
November 23rd, 2006 at 4:37 am
Something shell-based would be my first instinct–sort through the various mbox folders for emlx files matching a given date range, move them aside, then trigger a re-indexing somehow.
November 23rd, 2006 at 8:35 am
Mark, thanks for reminding me about that earlier post. Unfortunately, none of those options are automated and/or free.
November 23rd, 2006 at 9:14 am
@Craig - Nice solution within the restrictions that Mail sets. Thanks for posting that.
November 23rd, 2006 at 11:47 am
I have not tried this yet, but why not develop an Automator action? It seems like there are the tools in there (along with AppleScript) to get the job done.
Going to try it soon…
November 23rd, 2006 at 12:09 pm
Brett said:
“It’s easier to drop everything into a single folder…”
Unfortunately that won’t work forever:
“Mac OS X 10.3, 10.4 Mail: Overstuffed mailbox is unexpectedly empty” - http://docs.info.apple.com/article.html?artnum=25812
I tend to keep my mail a long time, deleting space wasting attachments (view by size and deal with the multi-MB mail messages), and have Filed Mail #xxx Mailboxes on my computer, each with about 500 messages in it. This translates to roughly about 20MB per folder.
When I archive, I burn the Mailboxes folder or a subset of the Mailbox folders inside it, using Toast. So far no need to automate the process.
November 23rd, 2006 at 9:54 pm
Well, reason with POP may be, to have a simple backup. I recently used Email Backup, just before my sweet little iMac G4 melt down. So I am quite happy with my old little POP Mails.
http://www.macupdate.com/info.php/id/22498.
November 24th, 2006 at 1:49 am
I don’t deny archiving makes sense as a strategy in some situations - I have to aggressively archive my corporate email to accomodate low disk quotas on the Exchange server, for instance. But it’s almost always to circumvent some technical limitation (quotas, empty mailbox bugs, the 2GB Outlook pst bug, etc.), not because it’s a productive workflow. Auto-Archiving introduces real problems with searching in Outlook/Entourage, even with Spotlight or Google Desktop enabled. (Google Desktop, in particular, has real problems with Outlook’s .pst files.)
I think archiving is just as personal a decision as the one folder / many folders distinction: if you’re used to archiving in one mail client, then the lack of another email client to do the same thing is viewed as a weakness. I personally dislike it.
I still think the cronjob/shell script solution is the easiest way to automate this on a Mac. It can be rolled into your other backup scripts so that your mail folders stay small and lean (if that’s your thing) and you don’t have to think about it.
November 24th, 2006 at 9:29 pm
Funny that so many people should ask this question at the same time as I’m in the same boat. Seems to me that Mail is old enough now that many people would have built up quite an lot of emails that somehow need archiving and easily accessible from within Mail.
The smart mailbox approach works in small quantities, but I feel Apple should look into an elegant solution within Mail.
November 25th, 2006 at 10:32 am
The scheduled backup part could be done with Apple’s Backup.app (v3.1), but it isn’t strictly free. There is even a “QuickPicks” set (that should grab the prefs too?) I just used it to backup my 848MBs worth of mail with Mail.app open; I don’t know how safe that would really be…. It does create a date labeled file, so the backups won’t get overwritten.
On an aside, I recently started using a smart-folder for the opposite effect: “show me everything for just this week that has not been read”.
November 27th, 2006 at 9:44 pm
Am I missing something here?
Just make a rule with
‘Date Received’ ‘Is Greater Than’ ‘7′ days old to move it to another folder.
ok, so we’re not out of the app yet, but out of the inbox and out of the way.
It is at least easily accessible from outside as e.g archived.mbox
Or how about, after 7 days, just forward it to a gmail address and then delete the local one?
November 29th, 2006 at 2:31 am
Will that work on messages in all mailboxes, not just the inbox?
If so, then, d’oh!
November 29th, 2006 at 12:28 pm
This mail archiving issue gets pretty big when a sophisticated user creates tens of mailboxes, some with sub-folders, to organize a very large volume of e-mails from many people.
I came here hoping to find a script or application, free or not, capable of backing up e-mail based on search criteria, that can replicate such a sophisticated filing scheme in the archive.
Has anyone here used a mail backup utility called MailSteward? I have not explored it yet, but it may be a few steps beyond the more simple folder-saving-with-date-criteria methods described here.
Regards,
Glen
December 7th, 2006 at 11:40 am
I archive all my mail once a year and have been doing so for 20 years. For Mail, this consists of simply copying the mailboxes to another disk. Until Mail 2.0, I could reopen these mailbox folders easily with Mail individually and browse or search them. Since Mail 2.0, all my old mailboxes have to be imported into Mail, a lengthy and error prone process, it seems. Suddenly my old mail is much less accessible to me.
In my view archival is trivial. However, Apple is not doing its part to assure that Mail can always open older mail folders easily and transparently.