Mac OS X’s Mail: Keeps flagging random archived messages as unread

Posted by Pierre Igot in: Mail
October 23rd, 2007 • 2:16 pm

I have been using Mail as my e-mail client for many years without too many problems, even as my e-mail archive has grown to include hundreds of thousands of messages. It now weighs nearly 1 GB, and Mail is still performing well.

In recent months, however, I have been experiencing a new problem that I hadn’t encountered in the past, and I just do not know what to do about it. The symptoms are fairly simple. I have tens of thousands of e-mail messages that I have manually archived in various folders and subfolders (which are called “mailboxes” in Mail). I use POP3 for most of my e-mail accounts, so these are local mailboxes that are actually stored in my local “Mail” folder inside my home library.

All my archived messages are always flagged as read. I never file a message away with the “unread” status. It’s just not the way I work. So none of these mailboxes in Mail’s mailbox drawer should have that small label that appears next to them with a number indicating the number of unread messages that they still contain:

Unread message in mailbox

And yet, as you can see in the picture above, some of my mailbox folders do have that number label.

If I open them to check their contents or the contents of their subfolders, I find that indeed, somewhere inside the mailbox, there is a message flagged as “unread” or a mailbox containing such a message.

The problem is that there is no reason why this message should be flagged as “unread.” It is usually a fairly old message and it was definitely flagged as read when I archived it.

And it is, in fact, a recurring problem. After I see the number label and hunt down the messages flagged as “unread” and select them and flag them as “read,” things go back to normal… for a while. And then all of a sudden some archived messages in the same mailboxes appear flagged as “unread” again. It is maddening!

I cannot say for sure that it is always the same archived messages that Mail flags as “unread” for no apparent reason. My memory is not good enough for this. But I do know that this happens only when I browse the contents of my mailboxes. The mailboxes that I browse do not contain any unread messages, but then, as soon as I click on them to select them and view their contents, all of a sudden the number label appears with a number of unread messages, and the message list displayed by Mail does indeed contain a number of messages that are flagged as “unread.”

In other words, it is the very fact of selecting a mailbox that appears to cause Mail to refresh the count of unread messages and “discover” unread messages inside that mailbox that were not flagged as unread a moment ago.

I am not entirely sure, but it could very well be that this particular problem started after I experimented with the “vacuuming” trick back in March 2007. This particular experiment did cause some weird and not-too-reassuring problems, including one where some messages where flagged as unread in various mailboxes… I thought at the time that it was just a one-off thing, but now I am wondering whether I didn’t actually break something irreparably somewhere in my Mail folder.

It certainly looks as if Mail does go through some kind of rebuilding process when I select a mailbox that I want to browse, and that this rebuilding process is flawed and causes some messages to be flagged as “unread.”

I will probably experiment further and try to deleting some cache files again, including the “Envelope Index” file, but I am not too optimistic that this will actually solve the problem.

UPDATE: After further investigation, I can confirm that, even after trashing the Envelope Index file, which forced a complete re-import of all messages, I can still cause Mail to revert some messages to the “unread” state by simply rebuilding the mailbox that contains them. So replacing the Envelope Index file itself does not fix the problem.

On the other hand, if I trash all the files that the corresponding .mbox folder contains in the Finder, which include:


and just leave the enclosed “Messages” folder, which contains the actual individual .emlx e-mail message files, and then relaunch Mail and try to view the contents of that same mailbox, then I get a list of messages without any “unread” flags. And even if I rebuild the mailbox, I still don’t get spurious “unread” flags. So it looks like the problem is in one of the local files in the .mbox folder.

Strangely, however, after I do this, the only file that Mail recreates is an “Info.plist” file. And even more strangely, if I then quit Mail, trash this new “Info.plist” file, restore all the old files mentioned above (which I have kept elsewhere, just in case), relaunch Mail, and select the mailbox in question again, I no longer get any spurious “unread” flags—even if I try to rebuild the mailbox.

So who knows exactly what is going on here. But at least it looks like I have some sort of solution to my spurious “unread” flagging problem—albeit with a painful manual operation required for each affected mailbox folder.

2 Responses to “Mac OS X’s Mail: Keeps flagging random archived messages as unread”

  1. Arden says:

    It doesnt need to be quite as painful as it is now. I hqve a problem with Mail in which some messages sent from certain domains to certain addresses on IMAP wouldnt show up properly, often giving a phantom unread count. I figured out a way to retrieve my messages properly, which involves moving the rules files elsewhere and relaunching Mail. After a while, I automated this process with Automator. I completed the automation process by running the task regularly with crop. You should create a similar process if you have to do similar manipulations on a regular basis.

  2. Pierre Igot says:

    Do you think the whole problem has to do with Mail’s rules? I am a bit wary of moving my rule files, simply because I do use a number of important rules, and I also use Mail Act-On, which relies on rules to do its thing.

Leave a Reply

Comments are closed.