As requested:
Here is the actual script:
-- Check if Growl is running:
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
--Only display notifications if Growl is running:
if isRunning = false then
-- display dialog "Growl is not running"
end if
tell application "GrowlHelperApp"
-- Make a list of all the notification types
-- that this script will ever send:
-- set the allNotificationsList to {"New Email"}
set the allNotificationsList to {"MailNotify1", "MailNotify2"}
-- 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 prefpane.
-- set the enabledNotificationsList to {"New Email"}
set the enabledNotificationsList to {"MailNotify1"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
-- register as application "Mail" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "Mail"
registeras application "MailRulesScript" all notificationsallNotificationsListdefault notificationsenabledNotificationsListicon of application "Mail"
end tell
-- Mail Rule Trigger
-- tell application "Mail"
--set theSelectedMessages to selection
using terms from application "Mail"
on perform mail action with messagestheSelectedMessagesfor ruletheRule
repeat with thisMessage in theSelectedMessages
-- Process the current message
-- Grab the subject and sender of the message
set growlSubject to subject of thisMessage & "***xx"
set growlSender to my ExtractName(sender of thisMessage)
-- Use the first 100 characters of a message
set growlMessage to (content of thisMessage)
set growlLength to (length of growlMessage)
if growlLength > 100 then
set growlMessage to (characters 1 through 100 of growlMessage) & "
"
end if
set growlMessage to growlSubject & "
" & growlMessage
-- Send a Notification
tell application "GrowlHelperApp"
show rollup
notifywith name "MailNotify1" titlegrowlSenderdescriptiongrowlMessageapplication name "MailRulesScript"
end tell
end repeat
--end tell
end perform mail action with messages
end using terms from
-- *ExtractName*
--
-- gathers the name portion from the "From: " line
--
-- Source: robJ [http://forums.macosxhints.com/archive/index.php/t-19954.html]
to ExtractName(sender_)
if sender_ begins with "<" then
return text 2 thru -2 of sender_
else
set oldTIDs to text item delimiters
try
set text item delimiters to "<"
set name_ to first text item of sender_
set text item delimiters to oldTIDs
on error
set text item delimiters to oldTIDs
end try
return name_
end if
end ExtractName
---------
Thanks again for the help.