O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  

Buy the book!
Mac OS X Panther Hacks
By Rael Dornfest, James Duncan Davidson
June 2004
More Info

Label Your Mail
Bring Eudora's colorful labels to your Mail messages, and learn a little something about the Scripts menu and keyboard shortcuts in the process
The Code
[Discuss (0) | Link to this hack]

One thing many switchers from Eudora to Mail miss is the ability to flag, identify, and categorize messages within a mailbox by using different colors and associated textual categories. In Eudora, a labeled message appears in its mailbox with its text colored and the name of the label entered in the Label column, as shown in . This rather handy feature is unfortunately just not part of the Mail feature set.

Figure 1. Using Eudora's colorful labels to identify and categorize messages within a mailbox

Using simple AppleScripts, it's possible to duplicate this colorization in Mail—except for the Label column. That is, this hack allows you to select one or more messages, perform a menu or key command, and have the message lines change color as they are listed in a mailbox window. (In Mail, the background of the message line, rather than the text itself, changes color.)

The Code

Even the newest of newbies should be able to take a quick gander at this rather simple bit of AppleScript and understand what it does. It acts on any messages currently selected in Mail and changes the background color of each in its turn to orange:

-- Colorize Mail.app messages

using terms from application "Mail"
 on perform mail action with messages msgs
 tell application "Mail"
 repeat with msg in msgs
 set background color of msg to orange
 end repeat
 end tell
 end perform mail action with messages
 on run
 tell application "Mail" to set selectedmsgs to selection
 tell me to perform mail action with messages selectedmsgs
 end run
end using terms from

Now, here's the interesting part, and it's not limited to this hack alone.

Save the code to a file named Respond ASAP - Orange__ _ctl-o.scpt; that's three underscore characters (__ _), mind you. While you could call the script whatever you like (e.g., simply ASAP), there's magic in those last few characters. The ending characters (__ _ctl-o) assign the keyboard shortcut Control-O (that's the letter O) to the script so that simply selecting some messages and typing Control-O calls the script and colorizes the messages.

Save the script in your /Library/Scripts/Mail Scripts folder. If the Scripts or Mail Scripts folders do not exist, go ahead and create them.

Create a similar script for any other of the available colors: blue, gray, green, orange, purple, red, and yellow. All you need to change in the script for each is the name of the color. So, making the following change (as indicated in bold) and saving the script as /Library/Scripts/Mail Scripts/Reply Some Day_ __ctl-g.scpt provides a Control-G keystroke to turn messages gray:

set background color of msg to gray

Be sure to create one with the color none for use in removing a color label.

O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.