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!
Awesome! I edited/tested the vacuuming of the other indeces and Mail smokes now! I thought I was doomed to slowness. Not anymore.
I stessed about this for a week and jailbreak/terminal type fixes like above were not working, just found this on APPLE’s iphone forum, nothing to do with jailbreaking:
I had the same problem and resolved it easy.
If you have more accounts, find out wich one is causing the problem by going in to settings – E-mail and switch them of one by one.
Found it, go into mail’s trash and delete all mails.
That did it for me.
If problem comes back after sync, in mail settings choos – show 25 recent, and delete on your computer mail account first 25 mails and trash to.
Prob. you sended a photo from your iphone resently and the phone found it some how to be corrupt.
If you have multiple accounts, turn them on one at at time to figure out which one has the corrupt message, i use imap, so used a webmail interface on my PC to look for random messages that could be the problem (in trash, in drafts, sent, etc.) and deleted and purged them, and now MAIL OPENS NORMALLY AGAIN — I haven’t seen it download 25 messages in weeks.
Seems like the “corrupt photo message” is probably the problem! Or something similar… anyway hope this helps someone else!
i have read this site and there are more good link!