September 02, 2007

Managing email

Going through a major shift in job responsibilities, so what does a good geek of the Mac variety do? Start writing a bunch of Applescripts. Chandra thinks this one is silly, but I'm hoping that it will be useful. The idea is to let me compose and send emails without actually opening Mail. That way I can get some communication done without being distracted by new things to deal with. I know I could open it and change the settings so that mail isn't automatically retrieved, but that's a hassle.

To use it, I have an OmniOutliner document with four columns, and I put the body of the message in the notes. The biggest flaw in what I've got here is that it doesn't really check that the mail messages have been sent before quitting. If I can figure out how to do that I'll post an update.

-- fire up mail, send off some emails and quit -- requires a four-column OmniOutliner document (Subject, Sender, To, Cc) -- put the body of the message in notes tell front document of application "OmniOutliner Professional" set sourceRows to selected rows if (count of sourceRows) is 0 then set sourceRows to rows end if repeat with theRow in sourceRows set toField to value of cell "To" of theRow set ccField to value of cell "Cc" of theRow set subjectField to value of cell "Subject" of theRow set senderField to value of cell "Sender" of theRow set theBody to the note of theRow tell application "Mail" set newMessage to make new outgoing message with properties {subject:subjectField, content:theBody} tell newMessage set visible to true set sender to senderField make new to recipient with properties {address:toField} if ccField is not "" then make new cc recipient with properties {address:ccField} end if send end tell end tell end repeat -- wait a few seconds for everything to send...I've got a local mail server so this should be adequate delay 5 tell application "Mail" to quit end tell

Posted by Jason at September 2, 2007 06:11 PM