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

Announce new Mail messages with AppleScript Apps
In Apple's Mail.app, you can have it announce that you have received email from someone. Create an AppleScript in the AppleScript Editor. I call it "Announce Steve Mail" in this example. Use the following template:

tell application "Finder"
  say "You have new mail from Steve."
end tell
Save the AppleScript as a compiled Script in your "Mail Scripts" folder as "Announce Steve Mail." The location is ~Library -> Scripts -> Mail Scripts, where "~" is your user ID.

Then in Mail, select the Mail Preferences. Select the Rules icon. Create a new rule where the From selection is the email address you want to announce. Then in the actions area, select the Run AppleScript entry. The Choose... button then lets you select the newly created AppleScript "Announce Steve Mail." Then whenever a message is received from the email address you've used, Mail will announce the arrival.

[robg adds: A previous hint explains how to create customized voices for mail announcements...]

    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[8,298 views]  

Announce new Mail messages with AppleScript | 7 comments | Create New Account
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: davidcrickett on Jan 20, '04 01:12:19PM
This is a better hint. Scroll down to the slightly improved applescript. ;-)

---
davidcrickett

[ Reply to This | # ]

Announce new Mail messages with AppleScript
Authored by: raven42rac on Jan 20, '04 11:24:45PM

I followed your link, and it works awesome. I am just working on a way to have it not announce my junk mail.



[ Reply to This | # ]
Announce new Mail messages with AppleScript
Authored by: davidcrickett on Jan 21, '04 02:17:03AM

When 'junk' was one of the rules, you could just place junk as the first rule, then speakmailsender as the second. I don't get junk, so I didn't know it was speaking the junk messages now in Panther?

---
davidcrickett



[ Reply to This | # ]
Announce new Mail messages with AppleScript
Authored by: dogboy on Jan 22, '04 05:53:08AM

Create the rule using the following conditions:

Sender is in my address book
sender is in my previous recipients
message is addressed to my full name.

That should take care of most spam. The rules need to have the option of 'Message is not junk' to do this properly.



[ Reply to This | # ]
AppleScript and arguments
Authored by: jecwobble on Jan 21, '04 09:25:20AM

Can you pass an argument to an AppleScript and have access to it as either a variable or a property? If so, could you write a Mail rule that looks for emails from "Steve" then calls a more general AppleScript passing it "Steve" as an argument so that it uses Steve's name? Then you could write as many 'from' rules as you like, using only one AppleScript.

If you can't pass arguments, I suppose you could write a shell script that accepts one argument and uses it in an osascript call....



[ Reply to This | # ]
About those better voice
Authored by: nyarlathotep on Jan 22, '04 12:14:28AM

I just typed a bunch of friends names into that AT&T site and into the Mac, the Mac did a far far better job pronouncing their names.

Jeff



[ Reply to This | # ]
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 | # ]