Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Fix new message counts with Gmail IMAP and Mail Apps
IMAP with Gmail is an excellent solution for keeping email coordinated on multiple platforms. Unfortunately, the way that Mail.app and Gmail communicate means that there are a number of annoyances. My largest complaint is that the unread mail count is always double the real number. This disappears once the message is read in the inbox, but until then, it is misleading.

My solution was to write a quick AppleScript that marks the unread message in the folder [Gmail]/All Mail as read immediately on retrieval: Be sure to change Gmail IMAP to the name of your Google account. If you're unsure of the official name, add get accounts in the tell application section to find the official name. While this is far from an elegant solution, it could help until Apple and Google coordinate their efforts. If you have any suggestions to make this script more efficient, please share!

[robg adds: Although it's not stated in the hint submission, I believe the last step is to assign this script to run as a rule on all inbound Gmail messages...]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[14,125 views]  

Fix new message counts with Gmail IMAP and Mail | 13 comments | Create New Account
Click here to return to the 'Fix new message counts with Gmail IMAP and Mail' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Fix new message counts with Gmail IMAP and Mail
Authored by: bex on Apr 10, '08 07:41:11AM

This seems like it could fix one of my gmail problems. (I haven't tried the script yet), however I am still beginning to regret moving my email to gmail.

Does anyone else have these problems:
o Mail shows up with incorrect header information (i.e. in the mail list in mail.app the subject is X, opening the email reveals subject is really Y). This only happens in a folder that is filed to automatically by a rule
o Undo doesn't work post deletion, or worse, the email appears to be resurrected, but then disappears again a few minutes later

There are a few other "feel" issues, but all in all, gmail's IMAP support seems very forced and while not half-baked, occasionally feels that way.



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: squawky on Apr 10, '08 08:41:30AM

I think this falls under the "GMail is not really IMAP" problem - your messages aren't in folders, they're tagged with labels. Many folks have complained online about this - the All Mail folder contains all your messages (labeled or not), while each subfolder contains a copy of the message with that appropriate label. When you delete a message, you apply a label to it ("Trash"); when you "undelete" it, you remove the label... but that doesn't ask GMail to put it back into your Inbox, as you would expect (it probably goes to your All Mail folder instead).

I have not had a problem with the unread message count, though -- I used to see double counts until I set GMail to archive my mail when it is downloaded



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: joshforman on Apr 10, '08 09:04:51AM

If you do this, then you're going to also mark those messages read in the Inbox too, which I think defeats the purpose. If you can script Mail to refresh its mail counts, then that would be more useful.It doesn't appear this is the case though.

The other option is to set your Unread mailbox to show
1. Message is Unread
2. Message is not in Mailbox "All mail" (under account #1)
3. Repeat #2 for each account

---
Josh Forman

http://www.joshforman.com/



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: djc0 on Apr 10, '08 04:45:46PM

I tend to agree here. If you do still find All Mail as marked as read and the Inbox as unread you might just be experiencing a delay between mail.app and Gmail updating each other. Just wait a bit and all will end up "read".

The reason:

read in All Mail in mail.app => read in All Mail in Gmail => read in Inbox in Gmail => read in Inbox in mail.app

All via the wonders of IMAP.



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: Sesquipedalian on Apr 10, '08 11:06:16AM

... or just open Mail's preferences, click on the General tab, and set the "Dock unread count:" to "Inbox Only" instead of "All Mailboxes." Works perfectly for me.



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: stagger on Apr 11, '08 04:06:14AM

Even better: Create a new intelligent box that includes all unread mail NOT in All Mail, and then set the message counter to that box. This way you can still use your filter rules to move messages into the appropriate boxes without loosing their unread count in the dock.



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: wesg on Apr 20, '08 09:21:23AM

That's something else I should have added. It really helps.

---
2GHz Core 2 Duo MacBook
http://www.wesg.ca



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: rogov on Apr 10, '08 12:50:28PM

Any way to fix the double message return when searching in Mail? Searching returns a hit in both the Inbox and the GMail box. Yes, I know I could constrain the search to one box at a time, but sometimes I need to search all boxes because I don't know which box something is in.



[ Reply to This | # ]
This may help
Authored by: rhowell on Apr 10, '08 01:45:46PM
Fix new message counts with Gmail IMAP and Mail
Authored by: jdfrankl on Apr 10, '08 02:42:52PM
rogov wrote:
Any way to fix the double message return when searching in Mail? Searching returns a hit in both the Inbox and the GMail box.
I was having a similar issue with "All Mail". I solved it by excluding "All Mail" from Spotlight searches. I think you can take a similar approach to solving your problem. This tip may help you.

[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: thermophile on Apr 11, '08 01:07:31PM
First - run as a script, it works as advertised, that is the message in the All Mail box is marked as read while the message in the In box is marked as unread.

Second - I created a rule - If the message is from the Gmail account, then run the script. This failed to mark the message in the All Mail box as read and so there were two unread messages.

I am stymied as to how to fix. Currently I am simply using MailAct-On to run the script.

[ Reply to This | # ]

Fix new message counts with Gmail IMAP and Mail
Authored by: wesg on Apr 20, '08 09:26:38AM

I should add that to run the script automatically, open Mail preferences and create a new rule that is evaluated after every message. Use the option for "run Applescript" and select this script.

Currently, as mentioned by thermophile, the script only works regularly when run in script editor. Working through Mail doesn't seem to be quite as consistent.

---
2GHz Core 2 Duo MacBook
http://www.wesg.ca



[ Reply to This | # ]
Fix new message counts with Gmail IMAP and Mail
Authored by: riotshield on Apr 16, '09 01:18:41PM
I found another more simple solution, that can tidy things up in the Mail sidebar. check it here http://www.macosxhints.com/article.php?story=20080915174303761

It tells you actually how to remove the All Mail folder from the sidebar. i dont find the all mail folder useful, rather confusing since it appears in search results and message count when it shouldnt. just remove it and voila. you can remove other folders as well if you want

[ Reply to This | # ]