By spencer, Sunday, August 16, 2009 · 11:53 am

In my last post I described a VB Script for moving IMAP email from my inbox to an archive folder. As an interesting Apples to Oranges (or Apple to Microsoft?) comparison here is the Apple Script I use with Entourage to perform the same task. I will post two versions: one that performs the exact same task and a second version that is significantly longer that integrates with the popular Growl notification system for OS X. I would just like to highlight the overall simplicity and elegance of the Apple Script vs. the VB script. Yes I know their history is totally different and perhaps VB script is overloaded in usage these days but the point stands: the Apple Script is readable and intuitive while the VB script is neither.

Once again I apologize for the formatting but WordPress is butchering <code> posts lately and insert all sorts of uglies inside the code blocks and I don’t feel like fixing it at the moment.

tell application “Microsoft Entourage”
set acctName to “BA”
set folderName to “Archives”
set destFolder to null

set currMsgs to (current messages)
set currCount to (count of currMsgs)

if currCount is not 0 then
set folderList to folders of IMAP account acctName
repeat with x in folderList
if name of x is folderName then
set destFolder to x
move currMsgs to x
end if
end repeat
end if
end tell

And the second with Growl support:

tell application “GrowlHelperApp”
set the allNotificationsList to {“General”, “Move message”, “Error”}
set the enabledNotificationsList to {“General”, “Move message”, “Error”}

register as application “Entourage AppleScripts” all notifications allNotificationsList default notifications enabledNotificationsList icon of application “Microsoft Entourage”

if currCount is 0 then
notify with name “Error” title “Entourage Error” description “You attempted to move a message but no message was selected.” application name “Entourage AppleScripts”
delay 10
return
end if
if destFolder is null then
notify with name “Error” title “Entourage Error” description (“You attempted to move a message but the destination folder \”" & folderName & “\” is not valid.”) application name “Entourage AppleScripts”
delay 10
return
end if

– 1 Notification…
if currCount is 1 then
notify with name “General” title (acctName & ” Notification”) description (“1 message moved to \”" & name of destFolder & “\” folder of account \”" & acctName & “\”") application name “Entourage AppleScripts”
delay 10
end if

– Multi Notification…
if currCount > 1 then
notify with name “General” title (acctName & ” Notification”) description (“” & (count of currMsgs) & ” messages moved to \”" & name of destFolder & “\” folder of account \”" & acctName & “\”") application name “Entourage AppleScripts”
delay 10
end if
end tell

Add your own comment or set a trackback

Currently no comments

  1. No comment yet

Add your own comment

Powered by WP Hashcash



Follow comments according to this article through a RSS 2.0 feed


Jump to start of page | Jump to posts