Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!

Automatically disable unused accounts in Mail Apps
I use two email accounts, a personal Gmail (IMAP) account, and a work mail account (also IMAP). I can only access my work email from within my work network, as the server is not on the internet. So I whipped up the following AppleScript and Launch Agent to automatically disable my work account when I'm not at work.

Here's the AppleScript: The script checks to see if Mail is running, if it is, and it has not been running for longer than five seconds (of processor time), then it checks to see if the server work-server is available, and enables/disables the Mail account Work as appropriate. Obviously, you'll need to customize those values for your situation.

We also need a way to run this AppleScript automatically; for that we create a Launch Agent: Save the above as net.checkmail.servers.plist in your user's Library » LaunchAgents folder, and it will run automatically when Mail's plist changes (which happens every time you launch Mail). Good luck!

[robg adds: I haven't tested this one, and note you'll need to edit both code snippets to match your setup.]
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[4,313 views]  

Automatically disable unused accounts in Mail | 4 comments | Create New Account
Click here to return to the 'Automatically disable unused accounts in Mail' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Automatically disable unused accounts in Mail
Authored by: dfbills on Wed, Apr 2 2008 at 10:21AM PDT
Great script!

---
-d

[ Reply to This | # ]
Automatically disable unused accounts in Mail
Authored by: M. Sundbom on Thu, Apr 3 2008 at 8:06AM PDT
I get the Applescript to work if run manually. I changed "enabled" to "include when getting new mail" because I still might want to browse the "offline" account but don't want Mail to automatically check for new mail.
However, I can't get the Launch Agent to work. Is there anything else than "username" in the path that need to be changed?

[ Reply to This | # ]
Automatically disable unused accounts in Mail
Authored by: mathieson on Fri, Apr 4 2008 at 8:46AM PDT
Are you saving the plist file in "/Users/username/library/Launch Agents" ???
Did you change the path to the script in the plist according to where you put the applescript?

Bear in mind you need to log out then back in again to load the launch agent.

[ Reply to This | # ]
Automatically disable unused accounts in Mail
Authored by: M. Sundbom on Mon, Apr 7 2008 at 6:12AM PDT
"Bear in mind you need to log out then back in again to load the launch agent."

Thanks, that made the trick.

[ Reply to This | # ]