Skip to content

Instantly share code, notes, and snippets.

@t0d0r
Last active December 11, 2015 21:48
Show Gist options
  • Save t0d0r/4665082 to your computer and use it in GitHub Desktop.
Save t0d0r/4665082 to your computer and use it in GitHub Desktop.
mail2grow apple script
global isRunning
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
on show_growl_popup(ruleName, senderAddr, subjectText)
# local theSender
set thePriority to 2 # default high
set msgTitle to ruleName & "/" & senderAddr
set isOK to word 1 of subjectText
if isOK = "OK" then
set thePriority to -2
end if
# set theSender to sender of theMessage
tell application id "com.Growl.GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"eMail Notification", "Another Test Notification"}
-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the Growl preferences.
set the enabledNotificationsList to ¬
{"eMail Notification"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"Growl AppleScript Sample" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Mail"
notify with name ¬
"eMail Notification" title ¬
msgTitle description ¬
subjectText application name "Growl AppleScript Sample" priority thePriority with sticky
end tell
end show_growl_popup
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with a from 1 to count theSelectedMessages
-- Process the current message
set ruleName to name of theRule
set theMessage to item a of theSelectedMessages
set theSender to sender of theMessage
set theSubject to subject of theMessage
if isRunning then
# show_growl_popup(ruleName, theMessage)
show_growl_popup(ruleName, theSender, theSubject)
end if
end repeat
end perform mail action with messages
end using terms from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment