Automatically disable unused accounts in Mail |
|
|
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:set run_result to (do shell script "ps ax|grep Mail.app|grep -v grep; echo -n")if run_result = "-n" thenelse set run_time to (do shell script "ps ax|grep Mail.app|grep -v grep|awk '{ print $4; }'") if run_time < "0:05.00" then tell application "Mail" try set ping_result to (do shell script "ping -c 1 -t 1 work-server") set enabled of account "Work" to true ...
|