You're in the kitchen cooking dinner, or sitting down watching TV, or exercising. Ding! You have a new email. Quickly, run to your Mac to see who it's from. Meh, spam. Ding! Meh, a message from your boss. Ding! Meh. Sure would be nice if Mail could announce who's emailing you. That way, you could just listen for ones you care about. Well, with the help of AppleScript and Mail rules, you can set this up on your own. Think of it as an audible caller ID, but for email.
Setting It Up
1. Launch AppleScript Editor (in /Applications/Utilities) and create a new script document.
2. Enter the following script into the document.
NOTE: if you have any trouble following along, you can download the completed script here.
NOTE: If you wish to test the script, which is always a good idea, you can do so by running it in AppleScript Editor. Just select a message or two in Mail. Then, return to AppleScript Editor and click Run in the script document's window.
3. Make any adjustments to the properties at the top of the script to customize its behavior. For example, if you don't want the script to raise your volume if it's too low, change the raiseVolumeIfNeeded property value to false. If you don't want the script to read the first few paragraphs of each message to you, set the readFirstParagraphsOfEachMessage property value to false.
Modifiable Properties in the Script
4. Save the script in Script format to your Desktop as Mail > Announce New Emails By Voice.scpt.
Saving the script to the Desktop
5. Launch Mail, open its Preferences window, and click Rules in the toolbar.
Mail's Rule Preferences window
6. Click Add Rule to create a Mail rule.
7. Set the rule's description to Announce New Emails by Voice.
8. Set the rule to trigger if any of the following conditions are met: Account matches [Your Account]. If you have multiple accounts, click + and add each one.
9. Set the rule to perform the following action: Run AppleScript. From the list of scripts, choose Open in Finder.
Configuring the Mail rule
10. Copy the Announce New Emails By Voice.scpt script file from your desktop into the newly opened folder (this folder is ~/Library/Application Scripts/com.apple.mail in Mountain Lion).
Mail's rule scripts folder in Mountain Lion (in ~/Library/Application Scripts)
11. Go back to Mail and close and save the rule.
The configured Mail rule, set to run the script
Now, whenever a new message arrives for the accounts you specified, the rule should trigger the script, and the messages should be announced audibly. If you get tired of listening to the announcements or want to mute them, just open up Mail's Preferences > Rules window again and de-select the Active checkbox next to the rule. Happy Scripting!
You can disable the Mail rule by de-selecting the Action checkbox
View the full article