Addressing mailbox access errors in OS X Mail
Problems with Mail's index may lead to slowdowns and missing messages, but a quick rebuild can fix this.
Apple's Mail program in OS X for the most part offers a quick and basic approach to e-mail, but occasionally you may run into problems such as not being able to access messages, whether you get error messages or simply can't locate them.
Similarly to OS X's Spotlight search feature, Mail uses an index to show the available e-mail messages that have been downloaded to the program, listing information such as subject, sender, and whether messages have been read and linking this information with the respective message file.
Errors involving the index can result in a number of odd problems, including a mismatch of the unread Mail count (indicated by the circled red number in Mail's Dock icon) and the actual unread count; inability to find messages you know exist; odd slowdowns when browsing through your messages; and error messages that state the mailbox is in use.
If you are experiencing these problems with Mail, there are several things you can do about them. First, if you find yourself seeing mailbox-in-use error messages, try quitting and relaunching Mail and programs that interface with it, including the OS X Calendar and Address Book programs. In addition, try quitting all programs, log out and back in without preserving which windows and applications were open, and then open Mail.
If this does not clear the problem, or if you are also experiencing other problems such as slowdowns or missing messages, then try selecting your inbox and choosing the Rebuild option from the Mailbox menu. This should make Mail clear and rebuild the index files.
However, if files are corrupt Rebuild may not work properly, so if the problem still does not go away then try manually clearing the index files. To do this, select Library from the Finder's Go menu (hold the Option key to reveal the Library in this menu if it's missing). Then go to the Mail > V2 > MailData folder in the library and remove the files that begin with the name "Envelope Index."
With these files removed, relaunch Mail. The program should now properly index your messages, allowing you to locate them.