Jan 21, '04 09:56:00AM • Contributed by: jaysoffian
I wrote the following AppleScript that I fire up whenever I start mail. It runs in the background, and once every five minutes it toggles each online IMAP account offline/online. This causes Mail.app to update the new message counts for each folder. Works great for me, your mileage may vary.
Here's the script:
To use, fire up Script Editor, cut and paste in the code, then save it with File Format: Application; Options: [ ] Run Only, [ ] Startup Screen, [X] Stay Open. Then just fire it up whenever you start Mail.app (it will start Mail.app for you if you don't).
on checkMail() tell application "Mail" set everyIMAPAccount to every imap account repeat with eachIMAPAccount in everyIMAPAccount tell eachIMAPAccount -- cycle online status of each enabled and online account, -- causing mail to update the status for each folder if (enabled and include when getting new mail) then set include when getting new mail to false set include when getting new mail to true end if end tell end repeat end tell end checkMail -- Loops until the background activity of Mail has stopped on waitForNoBackgroundActivity() repeat tell application "Mail" if (background activity count is equal to 0) then exit repeat delay 5 end if end tell end repeat end waitForNoBackgroundActivity on run checkMail() end run on idle waitForNoBackgroundActivity() checkMail() return 300 end idle