**Function:** Optimizes the Apple Mail database, drastically improving performance (your mileage may vary). Quits and relaunches Mail during execution.
**Author**: [Automator World](http://www.automatorworld.com)
**Notes**: This workflow is based on a [discussion](http://www.hawkwings.net/2007/03/01/a-faster-way-to-speed-up-mailapp/) at Hawk Wings. This workflow is probably best used as an iCal plug in, set to run once a month or so:
1. Open the workflow in Automator, and go to *File > Save As Plug-in...*
2. Choose *iCal Alarm* from the pop-up. iCal will launch, placing the workflow on today's calendar box.
3. Select the *Repeat* pop-up from the day's info window, picking the frequency desired (once a month is probably fine). Also set a time of day it won't be obtrusive, like 2am.
.1 update: no longer requires separate "Quit" action.
Thanks for this. I was going to set up my own, but now I don’t have to! :)
Comment by Kevin Donahue — March 3, 2007 @ 11:03 am
Wish your workflow included quitting and reopening Mail around the sqlite command.
Comment by Ben — March 3, 2007 @ 12:48 pm
Oops, I had uploaded the wrong version. The correct one is up, with quit/relaunch Mail. Sorry about that.
Comment by Steve — March 3, 2007 @ 4:46 pm
Automator complained about a missing Quit Application (or something like that). So I replaced it with another Run Shell Script using:
osascript -e ‘tell app “Mail” to quit’
I suppose this could be added to the part that runs the sqlite3 command.
Comment by Jim — March 4, 2007 @ 1:49 pm
Jim – I had removed the Quit action for that reason (which I didn’t realize was a 3rd party action, available here), and replaced it with the same Applescript step you posted.
Comment by Steve — March 4, 2007 @ 1:57 pm
Wonderfull, wonderfull!!
my Mail.app was getting soooo slow I was thinking of trying other email applications. Thought Mail couldnt handle that many emails….
Now, after using this Mail runs as smooth as when i started using it. No more waiting 15 secs when looking into another folder. And after this cleanup the envelope file is still +50 MB which, i get the impression, is quite big…
thanks!
Comment by Edo — March 5, 2007 @ 2:28 pm
YES YES YES YES!
Holy cow… this is the greatest little app I’ve ever seen.
Why doesn’t apple just make my mac do this on its own?
The improvement in speed was INSTANT and AMAZING.
Comment by JC — November 15, 2007 @ 2:42 am
Wow! Nice. Finally, I can use mail without fumbling around for the terminal and the vacuum script! SWWEEEEET.
Comment by Shauna Kinney — July 20, 2008 @ 5:40 am
[…] has created a clever Automator (based on an AppleScript no longer available) workflow “Mail Vacuum“ that cleans out the Mail storage database thereby improving the performance of the Mail […]
Pingback by Power up your Mail experience | Smoking Apples — December 8, 2008 @ 4:30 am
Is this safe also with current Mail in Leopard? I see that this is quite a while ago and perhaps there are updates?
Comment by Jorritsma — February 20, 2009 @ 9:18 am
[…] I also got a tip from #macosx to google around for “mail vacuum sqlite3″ and found an automator script to take care of that for […]
Pingback by Daily Review #7 | The Queue Blog — October 19, 2009 @ 10:26 pm
[…] want to tie it to a Calendar event to run every month or so. The Automator script can be downloaded here. From what I can tell, it simply runs the “vaccum;” command on everything. To set up […]
Pingback by Fix Mail.app Search Issues and Speed Up Apple Mail with This Simple Script | HighTechDad Blog — January 4, 2010 @ 1:23 pm
My Mail problems are fixed, thanks on the programmer.
Comment by Gottfried Auer — June 29, 2010 @ 12:21 pm