AppleScript is cool
By Adrian Sutton
I hate how slow Entourage is when accessing an imap server. Most of it’s problems stem from the fact that it only downloads things from the server when you actually ask for them. While that’s great for saving bandwidth, it means a lot of latency between clicking on a message and actually getting to see it – particularly since Entourage and imapd don’t seem to get on much and occassionally just hang the connection.
So I’ve switched to Mail.app (again). I go through these fazes of choosing different email clients until I get sick of their particular limitations. The greatest problem with Mail.app is that it only checks the email in your inbox and not in any other folders so if you happen to use procmail on the server (as I do) you have to manually click through every mailbox to see if there’s any new messages.
The solution? Applescript. Originally I added the following line to my crontab and was happy:
osascript -e 'tell application "Mail" to sychronize with account "adrian@intencha.com"'
The trouble being that if I quit Mail, cron would start it again every minute. A little more applescript to the rescue:
tell application “Finder”
set appIsRunning to process “Mail” exists
end tell
if (appIsRunning) then tell application “Mail” synchronize with account “adrian@intencha.com” end tell end if
Now Mail will synchronize every mailbox in the IMAP account every minute (I’ll probably drop that back to every 2 or 3 minutes) but do nothing if Mail isn’t already running. Applescript is cool.