Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Growl version' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Growl version
Authored by: Diggory on Jan 29, '08 09:15:42PM
Here's a similar script I use that uses Growl to notify of incoming mail. It launches the Address Book app (due to getting the picture of the sender, if available) - which some people find annoying, but I mitigate this by getting the Address Book app to be launched and hidden on login by the Accounts prefpane.

to getPictureForEmailAddress(personEmailAddress)
	tell application "Address Book"
			set thePerson to (first person where the value of emails contains personEmailAddress)
			set thePiccy to image of thePerson
			return thePiccy
		end try
	end tell
end getPictureForEmailAddress

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		-- 	display dialog ("Got here.  ")
		tell application "Mail"
			repeat with thisMessage in theMessages
					-- If this is not being executed as a rule action,
					-- getting the name of theRule variable will fail.
					set theRuleName to name of theRule
					set theSubject to subject of thisMessage
					set theSender to sender of thisMessage
					set theJunkStatus to junk mail status of thisMessage
					set theReadStatus to read status of thisMessage
					--	We don't need to be notified of Junk
					if (theJunkStatus is true) then
						log ("junk")
					end if
					--	Extract the email address and display name of the sender
					set theSendersName to extract name from sender of thisMessage
					set theSendersAddress to extract address from sender of thisMessage
					--	Find the sender's piccy
					set thePersonsPicture to my getPictureForEmailAddress(theSendersAddress)
					-- Check for spam not caught by Mail - but caught by Mail Provider's Anti-Spam.
					--	Your provider's warning string maybe different.
					if ((theJunkStatus is not true) and (theSubject does not contain "[**SPAM**]")) then
						if (theReadStatus is false) then
							tell application "GrowlHelperApp"
								set myAllNotesList to {"Mail Received"}
								register as application "Mail Notification Script" all notifications myAllNotesList default notifications myAllNotesList icon of application ""
									notify with name "Mail Received" title theSendersName description theSubject application name "Mail Notification Script" image thePersonsPicture
								on error the errorMessage -- user without picture in adressbook
									notify with name "Mail Received" title theSendersName description theSubject application name "Mail Notification Script" icon of application ""
								end try
							end tell
						end if
					end if
				end try
			end repeat
		end tell
	end perform mail action with messages
end using terms from

monkeyfood software -

[ Reply to This | # ]