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.
Keep up with the latest gadget goodness! -
Subscribe to our feed
Live from Macworld 2009
The Appletell staff is working their way through the show floor at Macworld 2009 to bring you the latest Apple products and accessories. Hit the Macworld page for non-stop coverage...
Live from CES 2009
We're live from the world's largest tradeshow. Hit up our dedicated CES page for keynote coverage, product announcements, interviews, and photo galleries from the show floor. We're excited... are you?





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