Highlight Apple Mail message a color with keyboard

Hello,

I want to be able to press a keyboard combination and change any highlighted message (or messages) to a specific color. For example, if I press 1 (or Cmd-1 or some other combination) with a message selected in Apple Mail, the message will change to background color red, 2 will change to green, etc. This is similar to what Mozilla Thunderbird can do.

I am new to Applescript, and I am having trouble creating even a very simple one to do this. I named the applescript Red, and it will take one message and color it red. I wrote it as follows:

tell application “Mail”
set background color of message to red
end tell

It does not work. Does anyone have suggestions to 1. make it work, and 2. make it work when multiple messages are selected at once? Thanks for the help!

Jason

Hi Jason - you need to identify the target message more specifically:


tell application "Mail"
	set theSelection to selection
	set thisMessage to item 1 of theSelection
	set background color of thisMessage to red
end tell

Or, to do it for all selected messages


tell application "Mail"
	set selectedMessages to selection
	repeat with thisMessage in selectedMessages
		set background color of thisMessage to red
	end repeat
end tell

[plug]
And if you don’t already have a solution for attaching the script to a keystroke, my FastScripts utility would be an excellent choice, I think :slight_smile:
[/plug]

Hope this helps!

Daniel Jalkut
www.red-sweater.com