A script to selectively enable accounts in Mail

Mar 21, '05 10:13:00AM

Contributed by: Anonymous

When I go on vacation, I change the accounts that are automatically checked by Mail.app. Each account has to be changed individually in Mail's preferencess dialog, which is a pain. So I wrote this short AppleScript to automate the operation for me:

tell application "Mail"
  set account_List to (name of accounts)
end tell
set selected_Accounts to (choose from list (account_List) ¬
 with multiple selections allowed without empty selection allowed)
if selected_Accounts is not false then
  tell application "Mail"
    set include when getting new mail of every account to false
    repeat with this_account in selected_Accounts
      set (include when getting new mail of account ¬
       (contents of this_account)) to true
    end repeat
  end tell
end if
The script will display a list of accounts to be checked (highlight more than one by holding the Command key down), and makes the appropriate changes to the preferences automatically. Any account you do not select will not be checked.

Comments (2)


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