Mail.app: IMAP Folders not updating?

January 2nd, 2008 by Jonathan Johnson

Ever since switching to Leopard, Mail.app sometimes doesn’t update folders with new messages, even if the messages added to those folders are a result of rules in Mail.app. I searched, and found partial solutions to my liking, but here’s what I settled on.

In Script Editor, save this script somewhere:

on run
  tell application "System Events"
    if exists (application processes whose name is "Mail") then
      tell application "Mail"
        set everyIMAPAccount to every imap account
        repeat with eachIMAPAccount in everyIMAPAccount
          tell eachIMAPAccount
            synchronize with eachIMAPAccount
          end tell
        end repeat
      end tell
    end if
  end tell
end run

Next, add a new rule to Mail.app that has the condition “Any Message,” and the action “Run Applescript” using this AppleScript. All this script does is automatically run “Synchronize” on each account any time a new message is found. This ensures that all folders are kept up to date.

I’ve been using this solution for a week now, and it’s been a godsend.

Edit:

See comments for a much simpler script.


COMMENTS

4 Responses to “Mail.app: IMAP Folders not updating?”

  1. Joe Ranieri Says:

    Seems to me to be a lot like Regularly synchronize IMAP folders in Mail

    Also, the AppleScript can be a lot nicer:

    tell application "Mail"
    	if not running then return
     
    	repeat with |account to synchronize| in every imap account
    		synchronize with |account to synchronize|
    	end repeat
    end tell
  2. Ryan Govostes Says:

    Wow Joe, that is a lot nicer. I should take some of the blame for that ugly entanglement of ends — I suggested he “simplify” the code into a single function. I don’t think any of us has as much AppleScript experience as you, though.

  3. Jonathan Johnson Says:

    Thanks Joe. It is indeed a lot like it, but I was aiming for synchronizing every account. The problem with most of the other solutions was that they either required a script per account or weren’t designed to be run from inside of a rule. I didn’t really write my script per-say, I came to it by simplifying/changing another complicated script :) I blame the original author ;)

  4. Adam Young Says:

    Thanks! This has been driving me nuts ever since switching to leopard. I even switched to Thunderbird (eww) for awhile.

Leave a Reply