How can I force Apple Mail to COMPLETELY refresh an IMAP account? I have a Gmail account that is configured on three different Macs, let's call them Home, Work, and MacBook. Home and MacBook are on iCloud, Work is not, and MacBook is the one experiencing the issue.

No matter what I seem to do, Apple Mail on the MacBook, for only this Gmail account, displays no messages in any folder, and indicates two unread messages in the inbox. Home and Work display the same account correctly, with an accurate reflection of the inbox and messages contained in other folders.

Things I have tried:


Synchronize
Rebuild
Disable account, quit, remove ~/Library/Mail/V2/IMAP-address@imap.gmail.com folder, then restart
Removed the keychain items for the account from iCloud, remove folder above


Each time, the account comes back with two unread messages out of zero. The Account Info screen shows accurate numbers for everything except the "Sent Mail" folder (though nothing in any folder displays). In experimenting with enabling and disabling IMAP for labels within Gmail, I have seen the item for the "Sent Mail" folder in Account Info display with the correct number of messages, but a title of "Sent Mail" does not exist. Very odd. Sorry I don't have a screenshot of that.

Any ideas?
I'm not sure if this will work for everyone, but I was able to resolve the issue in two parts. To get messages to display properly for all folders on the account, I needed disable/remove the account from iCloud so that it was no longer being synced. Then I removed the mailbox folder described in the question, and added it locally to the MacBook.

After the folders were displaying properly, the index was still a little messed up in that the inbox was displaying an unread count that didn't exist.

To get rid of this, I had to rebuild the full index -- this appears to be different from the Rebuild function that exists in the Mailbox menu, and is more similar to what happens when you open an upgraded version of mail for the first time.


Quit Mail
Navigate to ~/Library/Mail/V2/MailData
Delete any file that starts with "Envelope Index"
Start Mail
Follow prompts to allow Mail to rebuild the index -- this may take a few restarts of the app.