Manage automatic mail checking via AppleScript

Mar 17, '05 09:54:00AM

Contributed by: davidmorr

Eudora is a wonderfully flexible email program. It allows me to manage eight email accounts, and to check them for new mail every few minutes. Apple Mail can do the same. But there are some times when I don't want my email program to do this. One case is when I am trying to debug some problem that requires rebooting the Mac frequently. Another is when I don't want it to start up my Internet connection.

Now, I could fix this by going through all my personalities and unchecking "Check mail every x minutes" for each one. Then I would have to go through and check them all again when I wanted my mail to be checked automatically again. Too hard! AppleScript to the rescue...

The AppleScript below will tell Eudora (or Apple Mail) to check for new mail at time intervals you specify. Paste it into a Script Editor window, then Save As an application. You can either leave it on your desktop or put it into the Script Menu where it is convenient but out of the way. Now, mail will not be checked when the email program is started. When you want it to check for new mail regularly, run the script. This asks you how often to check for new mail, then tells the email program to check for new mail at that interval.

-- Manually check for new mail at regular intervals.
-- David Morrison, 25 December 2003
--
on run

  set check_interval to text returned of ¬
   (display dialog "How many seconds between checks?" default answer "600")

  repeat
    tell application "Eudora"
      connect with checking
    end tell
    delay (check_interval as number)
  end repeat

end run

on quit
  continue quit
end quit
Note that for each personality, you must have checked the box "Check mail on manual checks." If you want any personalities to be exempt from this, uncheck the box. This can also be used for Apple Mail. Change the tell ... end tell section to:
tell application "Mail"
  check for new mail for all
end tell
In the General Preference pane, set "Check for new mail" to "Manually." For each account, uncheck "Include when automatically checking for new mail."

Comments (5)


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