Quick Fix for Gmail IMAP-Mail Issues
For those of you who use Gmail IMAP in Mail as I do, you are probably just as annoyed with one thing- the new messages counter always reads twice the actual number. This is because the message is sent to both your inbox and the folder titled “Gmail” or “All Mail”. Just put the following into Script Editor, and voila!
tell application “Mail”
set unreadBox to mailbox “[Gmail]/All Mail” of account “Gmail IMAP”
set unreadCount to unread count of unreadBox
if unreadCount is not 0 then
repeat unreadCount times
set unreadMail to first message of unreadBox whose read status is false
set read status of unreadMail to true
end repeat
end if
end tell
Before running this script, you may have to type in the following in script editor in order to get the official name of your account:
tell the application “Mail”
get accounts
end tell
Once you have done this, change “[Gmail]/All Mail” to the name of the folder as it appears in Mail. Then, change “Google IMAP” to the official name of your account. This should do it!
Comment with any questions or if you have any suggestions for a more efficient script, do tell.
Subscribe to keep up with the latest Apple news and rumors! -
Subscribe to our feed
Black Friday 2009
Black Friday is almost here! Gadgetell's got you covered with all the latest news on who's offering the best deals. Dangerous crowds? You're on your own.
Our new podcast: Meet...
We know. Podcasts are so last year - but this one you won't want to miss. Whether it’s a rumor that won’t die, a new product announcement, or just a really good Macintosh or iPhone app find that we have to let you know about, we’ll make sure it’s covered on Appletellcast.
iPhone App Reviews
iPhone Apps. They were great when the App Store was first announced and we could all pick and chose what we wanted, but the number is now overwhelming. Here at Appletell, we'll detail the great iPhone apps we find, and steer you clear from those that aren't worth it even if they're free.
iPhone Game Reviews
As Apple turns the iPhone into one of the most popular gaming devices, the staff of Appletell--gamers and Apple fans alike--are here to help you get the most entertainment value out of your app store purchases.






Dude. Mail.app is not the one to blame for the email appear both in the Inbox and the Gmail/All folder. The “All” folder in Gmail contains all your mail ( Sent, Deteled, Forwards, Inbox etc ). Writing this script is an exercise in futility.
Google mentions this here:
http://gmail.google.com/support/bin/static.py?page=troubleshooter.cs&problem=bugflow&selected=bugflow_imap08
on April 13, 2008 at 10:59 AM - LINKI’m not blaming either Google or Mail.app for the issue, I’m simply putting out a way to remedy it.
on April 13, 2008 at 11:02 AM - LINK1) This was nicked from MacOSX hints
2) It’s a stupid idea there, too. If you mark your ‘all mail’ read, then it will have the effect of automatically marking all mail as read in other inboxes as well, so the next time it synchronizes it will pick up the changes and mark all mail read from other folders too.
The solution is to mark your inbox as your inbox, and then the new message count shows what’s new in the inbox. If you don’t do that, it shows all unread messages in all folders.
on April 13, 2008 at 11:28 AM - LINKYou can also handle this with Mail rules. I have one that moves all my sent mail to my Sent Mail folder and marks it read.
on April 13, 2008 at 01:36 PM - LINK