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


Click here to return to the 'Announce new Mail messages with AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Announce new Mail messages with AppleScript
Authored by: tekbreak on Dec 01, '08 05:10:42PM
I wrote a little script to automatically announce the sender's name of new emails received at Apple Mail.
This script extracts the sender's name or if it does not exist, the username of the email address.

on perform_mail_action(info)
	tell application "Mail"
		set theMessages to |SelectedMessages| of info
		repeat with thisMessage in theMessages
			set AppleScript's text item delimiters to {""}
			set thisSender to sender of thisMessage as string
			set texto to thisSender
			--set texto to (text items 2 through -1) of texto as string
			set inicio to (text items 1 through 1) of texto as string
			repeat while (inicio is equal to " ")
				set texto to (text items 2 through -1) of texto as string
				set inicio to (text items 1 through 1) of texto as string
				
			end repeat
			set menorque to offset of "<" in texto
			if menorque is 1 then
				set thisSender to (text items 2 through -2) of texto as string
				set arroba to offset of "@" in thisSender
				set thisSender to (text items 1 through (arroba - 1)) of thisSender as string
			else
				set thisSender to (text items 1 through (menorque - 1)) of texto as string
			end if
			tell application "Finder" to say "You have new e-mail from " & thisSender
		end repeat
	end tell
end perform_mail_action
Just copy it and paste it on a new script in Script Editor Application, then saveit to a file wherever you want.
Go to Mail Application preferences and create a new Rule just like that:
Box 1: select FROM
Box 2: select CONTAINS
Box 3: type this "@" (without quotes)
and then choose: Run Applescript and select the file you made before
... mail will ask you to apply the new Rule to every mail on your mailbox, you should select NO , if you don't, all your mailbox contain will be announce.

[ Reply to This | # ]