Mail shows stale inbox count I've had some odd behavior on my OS X mail client. Heres' my inbox: 



Yet here is how many unread messages I have: 



These values used to be synchronized. Note that the first value will not change even if I mark all other messages as read (subfolders included). 

OS X 10.7.4
Mail = Version 5.2 (1278)
Try these two solutions:


From the Finder, ⌥-click the Go menu and select Library whilst still holding ⌥.
Move the folder ~/Library/Mail/ to the desktop or another convenient location.
Launch Mail.app.
From the File Menu choose Import Mailboxes…
Choose Import Data from Apple Mail.
Navigate to ~/Desktop or wherever you moved ~/Library/Mail/ to.
Click on Choose.
Wait until it imports.


or


In a Finder window, navigate to ~/Library/Mail/V2/MailData, and delete any file that begins with Envelope Index, such as "Envelope Index" or "Envelope Index-shm" or "Envelope Index – awl". In my case, I had all 3 of these Envelope indexes, and moved them to the trash.

Note: When accessing Library, keep in mind that your home Library is hidden in Lion.  To access it, from the Finder, ⌥-click the Go menu and select Library whilst still holding ⌥.
Restart Mail. It will then rebuild a new list of messages, which can take some time, so be patient.

Another note for Exchange users: After removing the Envelope Indexes, my Exchange account email content was blank. To revive it, I had to delete my Exchange email account and add it again fresh.  After adding it from scratch (and the download took a while since I have about 12K messages), the mystery Unread Message notifications were gone.