Fix message counts and 'ghosts' in Mail's smart mailboxes

Aug 29, '05 07:51:00AM

Contributed by: moritzh

Out of all the great ideas I initially had for using smart mailboxes in Mail.app, only one I could actually implement due to Apple's decision to bless us with a really limited and sometimes incredibly stupid feature set in the GUI, hiding away most of what would be technically possible: That was having one smart mailbox showing all unread and another one showing all flagged messages.

From my previous experience and what I had read elsewhere about Spotlight and friends, however, it did not surprise me that these folders showed totally incorrect results, rendering the smart mailboxes completely useless for me. The message counts were totally wrong and there were even ghost messages which did not exist anymore in any real (as opposed to smart) mailbox. Mail.app would always say that those messages have not yet been downloaded; mostly those were really old messages. most of the 'ghosts' appeared several times.

So for months, I have been ignoring these smart mailboxes, occasionally doing some research on the Apple discussions and elsewhere about what could be the cause of the problem, but I could never find any appropriate info. Just now, however, I finally managed to fix it. I quit Mail.app, made a backup of my entire ~/Library/Mail/ folder (just in case), deleted the file Envelope Index from within that folder, restarted Mail.app, clicked OK in the message that Mail.app needed to import messages -- and finally had working smart mailboxes with correct results! Yeah, after months of using 10.4, the first possibly useful application of any of those smart things in Tiger is in sight!

I had been tempted before to try the method described, but the warning message that Mail.app would need to import messages had always made me cancel the procedure, as I was not willing to guide Mail.app through a tedious import procedure for the more than 16,000 messages in about 45 mailboxes. It seems that deleting the file Envelope Index really only forces the recreation of the index file (as the name of the file suggests), and has nothing to do with "importing" messages/mailboxes (as in File -> Import Mailboxes...) or losing other settings (as Mail.app's warning message suggested to me).

I had tried various other methods before which seeemed to be worth a try: turning Spotlight off and on, forcing the deleting and rebuilding of Spotlight indices, deleting Mail.app's cache files, recreating the smart mailboxes, rebuilding all mailboxes (Menu Mailbox > Rebuild), temporarily switching the caching of all messages and attachments in my IMAP accounts off and on, etc., but nothing had worked. It seems I was too much influenced by all this Spotlight advertising stuff which made me think that Mail.app was actually using Spotlight technology for this. Instead, it just uses an index file which has always been there, even before 10.4. At least, for pre-10.4 systems, it was used for read/flagged status, from/to/subject/date headers, etc. For searching message contents, Spotlight indices seem to be used, as I found out when I completely turned Spotlight off because it was just not useful, reliable and fast enough to depend on. So that's why the method described here could also be useful for someone using pre-10.4, but I haven't tried.

Comments (13)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050822185354706