Example 3: Delivery Notification

This example is a bit more elaborate. It uses Growl to show a notification when you receive an SMS Mac delivery report. Also, it tries to look up the name of the recipient in the Address Book.


Below is the AppleScript code.

to getNameForPhoneNumber(personPhoneNumber)
    tell application "Address Book"
set thePerson to (first person where the value of
phones contains personPhoneNumber)
set theName to name of thePerson
return theName
on error
return personPhoneNumber
end try
end tell
end getNameForPhoneNumber

using terms from application "Mail"
    on perform mail action with messages selectedMsgs
tell application "Mail"
set appName to "SMS Delivered Script"
set notificationName to "SMS Delivered"
set notifs to {notificationName}
tell application "GrowlHelperApp"
register as application appName all notifications notifs
default notifications notifs icon of application "SMS Mac Scripting"
end tell
repeat with msg in selectedMsgs
if not junk mail status of msg then
set theNumber to word 7 of paragraph 3 of content of msg
set theDate to date received of msg as text
set theName to my getNameForPhoneNumber("+" & theNumber)
set theDescription to "The SMS to " & theName &
                            " has been delivered on " &
tell application "GrowlHelperApp"
notify with name notificationName application name appName
title "SMS Mac " description theDescription
icon of application "SMS Mac Scripting" with sticky
end tell
end if
end repeat
end tell
end perform mail action with messages
end using terms from

Enter this code and save the script as "SMS Delivered.scpt" to your hard disk.

Launch Apple Mail.app and choose Preferences from the Mail menu. Click the Rules icon and then press the Add Rule button.

  • Give the rule a name, for example, Send Delivered.
  • Add the condition that the From field of the email must contain .
  • For the second condition add that Subject should be "Your SMS has been delivered".
  • Choose the action Run AppleScript from the Action popup menu and use the Choose button to select the script you saved above.
  • Click OK to finish the rule.
Mail Rule

When you receive an email with a delivery report Growl will show you a notification.

Home Page


Address Book Plugin:
Mac OS X 10.3 and up
Send SMS Widget:
Mac OS X 10.4 and up
Yahoo! Widget:
Windows XP, 2000

Discussion List