Avoid 'Working Offline' issues in Mail.app

Mar 01, '05 07:13:00AM

Contributed by: Anonymous

I've always been bothered by Mail.app's "Working Offline" mode. I have two email accounts -- one for my domain and one for Gmail. If the POP server for one of them (or my network connection) goes down, Mail fails silently and won't check that account for new mail until I manually bring that account back online.

I finally wrote an AppleScript to get around this annoying problem.

Open up Script Editor and paste in the following code:

on checkall()
  tell application "Mail"
    repeat with each_account in every account
      tell each_account
        check for new mail for each_account
      end tell
    end repeat
  end tell
end checkall

on isrunning()
  tell application "System Events" to ¬
    set mail_running to (exists process "Mail")
  return mail_running
end isrunning

on runloop()
  repeat
    if isrunning() then checkall()
    
    delay 1 * minutes
    -- change this number to how often you want to
    --check all of your accounts for new mail.
  end repeat
end runloop

runloop()
Choose Save As... from the File menu. Change 'File Format' to Application Bundle, make sure that none of the checkboxes are checked, and save the file into your Home folder or your Applications folder (well, anywhere, for that matter). Call it "Mail Checker" (or something like that). Just make sure you remember where you save it.

Now, in the Finder, go to where you just saved that file. Hold down the Control key and click on it. Choose "Show Package Contents," and a new Finder window appears. In the new window, open the "Contents" folder and open "info.plist" in TextEdit, or a text editor of your choice. After the opening <dict> tag, add the following two lines:
<key>NSUIElement</key>
<string>1</string>
Now save the file. This step simply makes the dock icon for the application hidden -- you don't want to have an application icon appear in your dock every time it checks for new mail. Close the document window and the "Contents" finder window, but leave the other Finder window (containing the Mail Checker script) open.

Now, you need to make this script run each time you login on your computer. The following instructions are for Panther only. Go to System Preferences and open the Accounts pane. Choose the Startup Items tab. Drag the Mail Checker script from the Finder to the list box in the Startup Items tab. It doesn't matter where it is in the list, or if the hide box is checked. Quit System Preferences.

To keep Mail's automatic checking from conflicting with this script's automatic checking, you need to turn Mail's off. Go into Mail preferences, General pane. Change "Check for new mail" to "Manually." Close the prefs window.

Now you're ready to launch the script and behold its amazing offline-overriding abilities! Double-click its icon in the Finder, and enjoy!

[robg adds: I haven't tested this one.]

Comments (16)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050226180321946