Wednesday night, I tackled a project I've been putting off for, well, years: cleaning out my Mail archives. And by "archives," I really mean "messages stored in folders and sub-folders and sub-sub-folders in Mail itself that I meant to one day do something with but never got around to handling." While the project went well in the end, there was a point where it appeared I'd lost hundreds of important messages. If you find yourself in a similar situation, this tip may help.
I spent a few hours archiving (really archiving, via Mail's built-in Mailbox -> Archive Mailbox menu item) more than 12,000 messages and removing hundreds of megabytes worth of no-longer-needed file attachments. Throughout the entire process, there was only one folder I didn't touch--my Software Keys folder. This is where I keep the original copies of any software serial numbers I receive via e-mail. (I also put the key itself into Keychain Access, but that's just the key.) I like to keep these around in case I ever need to contact the software vendor.
The only thing I did to that folder during my cleanup was move it out of a sub-folder. After purging all my old e-mails, I opened the Software Keys folder, saw all my saved messages for a brief second...and then they just vanished. Poof. Gone.
Rebuilding the mailbox (Mailbox -> Rebuild) didn't bring them back. So I turned to Time Machine, which was able to restore the folder, or so it seemed. But when I then moved the imported messages back into the original Software Keys folder, only one message showed up, and I couldn't even view the contents of that message. At this point, I thought I was stuck, and the messages were just gone for good.
Then I remembered an older hint about fixing a sluggish Mail app. While my Mail app wasn't sluggish in the least, after reading the hint I suspected perhaps I had an index problem. So I used the brute force method in that hint to try to fix it: I quit Mail, then moved the file named Envelope Index from my user's Library -> Mail folder to the trash. (As noted in the original hint, please make sure you have a good backup before doing anything like this...just in case it all goes horribly wrong.)
When I restarted Mail, the application told me it needed to import my messages; I clicked Continue and then just waited a bit. After a few minutes, Mail told me it had imported 3923 messages. I navigated to the Software Keys folder, opened it up, and found all the missing messages. I opened each one (to be sure they worked), and then started a new Time Machine backup immediately, so the corrected data would be backed up.
After this close call, I've also resolved to clean out my old Mail messages on a more regular basis--not only will it keep Mail running faster (it's like a new app this morning!), but will hopefully prevent my index file from becoming so badly mangled that it no longer functions at all.
This story, "Recover Apparently-vanished Messages in Mail" was originally published by Macworld.