Change Mail’s reply message font

Someone asked about scripting Mail so that they could easily change the font when they replied to an email.

I asked for a million dollars.

(Not really.)

I’d almost rather script a non-scriptable application than try to script Mail. Mail is scriptable, but it’s generally a pain in the rear to do so. What should be easy to automate using scripts in Mail, usually isn’t. I plan to write a long, haranguing diatribe someday about how much Mail sucks rocks and how Apple has foisted such a buggy piece-of-blank upon us. I’d like to suggest that instead of taking that huge cash surplus they’ve generated and giving it back to shareholders, they take that money and bring iCal and Mail into the 20th century. I’ve already abandoned iCal in favor of BusyCal and tried to abandon Mail in favor of Outlook for Mac. (The only thing worse than Mail is Outlook for Mac. I didn’t think that was possible, but Microsoft has done it, and done it well.)

I spent some time trying to work out the most elegant way of creating something that the person requesting the script could use. I had to forego elegant for tacky. The person was using 10.6 (Snow Leopard), and this script works on 10.6. It does not work on Lion, but I think it’s probably easily adapted to work on Lion if needed: change_email_font_to_verdana.scptd

Basically, the script assumes that Mail is running and that the frontmost window is the reply message and that you haven’t moved the cursor since pressing command-r or clicking the reply button. Trying to have Mail choose a font via GUI scripting was a complete pain. Instead, I opted for creating a style, which Mail would select and apply to the text in the content section of the open and frontmost reply message window. When the script is run, it searches for the style. If the style doesn’t exist, the script creates it using TextEdit.

The person who requested the script wanted 12 point Verdana, so that’s what the script is set up to use, but if your preferences are different, it’s fairly easy to change the script so that it works for you. Note that the script is actually a script bundle (.scptd), meaning that the script file is actually a folder dressed up like a file. Script bundles make it easy to add items to a script, keeping everything together. Script bundles can hold things like sounds, pictures, icons, and other resources within a script. Our script bundle holds a TextEdit file containing the text whose style we want to copy. By changing the style of the text in the TextEdit file, we can change the text that Mail applies to our reply messages.

To change the text from Verdana 12 to Sabon 14, for example, control-click on the script bundle. As seen in the image, a contextual menu will appear. Select Show Package Contents to open the script bundle.

"Screenshot of Show Package Contents"

In the image here, contents appear in expanded list, and the sample text.rtf file is selected. Once you’ve navigated to the sample text file, open it.

"Screenshot of package contents"

It’s a TextEdit document and it contains the words sample text in 12-pt Verdana. When you run the script, the script copies this text, creating and saving a style using the font of the sample text.

"Screenshot of sample text window"

Press command-a to select all, then change the font, choosing the attributes you want. In the example shown, I’ve chosen 14-pt Sabon. After making the changes, save and close the document. Now, when you run the script, the font attributes you’ve selected will be used.

"Screenshot of new sample text window"

Update: It’s probably going to get really annoying pretty quickly if you have to type command-r, so run the script using Quicksilver, FastScripts or something similar. I’ve been recently introduced to the wonders of Keyboard Maestro by Eugene Gordin of Simply Apple and I think Keyboard Maestro’s ability to intercept keystrokes for a specific application would serve perfectly here. Using Keyboard Maestro, you could set up command-r in Mail so that instead of getting just a reply window, you would get a reply window and the script would run.

Update: Of course, I would find out after sweating through creating a script that other solutions already exist: Message Font and Universal Mailer. I haven’t tested these plug-ins using Snow Leopard. I have tried Universal Mailer on Lion and it didn’t work. The Universal Mailer FAQ states that other Mail plug-ins can interfere with Universal Mailer, which may have been the problem.

05. August 2012 by sojourner hardeman
Categories: geekery | Tags: | Leave a comment

Leave a Reply

Required fields are marked *