Today I was trying to find an email in my Apple Mail and went to my usual trustworthy internal mail search function only to find that the “Entire Message” field was grayed out for all of my accounts. Granted, I use a mixture of POP3 and IMAP account and my main IMAP account has about 8400 messages in my inbox (hmm, maybe I should start filing those?).
After doing some quick searches, I came across a little script or command that you can run in the Terminal which helps to optimize your email subject lines. In fact, after reading through some of the comments on this post which talks about the process, you can run the same command of “vacuum” on a variety of the tables within your Mail.app database (e.g., addresses, messages, attachments, threads, etc.).
Here is the simple script that you can run:
- Exit out of your Mail application
- Launch Terminal (if you don’t know what this is, you might want to just get the Automator script that is linked below).
- Type in the following:
sqlite3 Envelope Index
- You will see a new prompt that says “sqlite>”
- At the prompt, type (don’t forget the semi-colon):
- It may take a few seconds (it took mine a while) for the script to run. This depends on the size of your mail database
- When the script has finished, you will see the “sqlite>” prompt again.
- Push CTRL-D to exit out of sqllite.
That’s all that you have to do. You will definitely see some improvements in your Mail application speed. Also, this corrected the error that I found with the “Entire Message” field being dimmed out. Corrected resulting image shown below:
I read through some more of the comments and one user commented that you can also “vacuum” other tables. I have not tried that so let me know what the results are if you try it. To do that, after the “vacuum subjects;” command, simply type:
There are some other tables in there (like “properties”) but I think the ones above are the most critical.
Lastly, you can download an Automator script that can do this for you automatically. And, you might even 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 the Automator script based on a calendar event, do the following:
- Download Mail Vacuum 1.1
- Unzip and move the Automator script somewhere where you can save it (e.g., the “Applications” directory)
- Open the script in Automator
- Choose “Save as” and then select type “Application”
- Exit Automator
- Launch iCal
- Create a new Event
- Under the Alarm section, choose “Open File”
- Choose the Automator Application you just created.
- Set up a repeating event (optional) – I set mine to repeat monthly for a year.
From my understanding, the SQLite “vacuum” cleans up the main database “by copying its contents to a temporary database file and reloading the original database file from the copy.” This does some essential database optimizations. More details on the SQLite “vacuum” command can be seen here.
Did you find this solution useful? If so: [paypal-donation reference=”Mail.app vaccum”]
HTD says: Let me know how this tip works for you! It definitely fixed my Mail.app search problems!