ZedneWeb
Since 1996

Updated Mailsmith notifier for Growl

By Dave Menendez
Saturday, April 16, 2005, at 3:57 PM

Summary: I’ve revised my notification script for Mailsmith to be compatible with Growl 0.6

Last October, I posted some sample code for a Growl notifier for Mailsmith. Unfortunately, the 0.6 release of Growl changed the AppleScript API and broke my script.

Here is an updated version that works with Growl 0.6:

on run
    tell application "GrowlHelperApp"
        register as application "Mailsmith Notifier" ¬
            all notifications ["Incoming mail", "Error"] ¬
            default notifications ["Incoming mail", "Error"] ¬
            icon of application "Mailsmith"
    end tell

    tell application "Mailsmith"
        set unreadCount to unread interesting
    end tell

    set unreadCount to unreadCount & " unread" as string
    tell application "GrowlHelperApp"
        notify with name "Incoming mail" ¬
            title "Incoming mail" ¬
            description unreadCount ¬
            application name "Mailsmith Notifier"
    end tell
end run

on ErrorLogged(theMessage)
    tell application "Mailsmith"
        set msg to (name of theMessage)
    end tell

    tell application "GrowlHelperApp"
        notify with name "Error" ¬
            title "Error" ¬
            description msg ¬
            application name "Mailsmith Notifier"
    end tell
end ErrorLogged

Because the script now registers with Growl, you can control how Growl treats the incoming mail and error notifications in System Preferences.

This is still imperfect. The registration command should probably be moved into a separate routine and called from the error notifier as well. (Alternately, you could put registration in a separate script and only call it once. I’ll have to experiment.)

More frustrating are some limitations in Mailsmith. Whatever algorithm Mailsmith uses to calculate the number of unread messages gets confused if you delete mail. I’ve seen messages saying things like “-2500 unread”, which is obviously nonsensical. In any case, what I want is the number of new messages, not necessarily the number of unread messages.

Mailsmith’s error messages use some non-ASCII characters in their subject lines, but rather than provide them as a Unicode string, Mailsmith returns subject line in quoted-printable encoding. As a result, I see notifications like this,

Error -3220 receiving mail from =?iso-8859-1?Q?=B3mail=2Esecondsaturdays=2Eorg=B2?=

instead of,

Error -3220 receiving mail from “mail.secondsaturdays.org”

Annoying, but not unbearable. One of these days, I’ll write to Bare Bones and ask them about it.