Today John Gruber posted an excellent set1 of AppleScripts that automate replying without top-posting in Apple’s Mail.app. You can read his article for the full description.
It’s exactly what I’ve been looking for to allow myself to keep my anal-retentive e-mail replying habits and increase productivity. However, I had one problem with his implementation: it doesn’t handle signatures gracefully.
I have a couple different e-mail accounts in Mail.app that I use on a daily basis and each has a unique signature (which also helps me know which account I’m replying from), but his script dumps you after the signature if you have one set to be auto-selected. I could just set it to select “None” by default, but then I lose the increased efficiency by having to select the signature.
So, I came up with a four-line addition to his script which adds the following fourth step to his process:
- If no default or random signature is selected, select the first signature from the pop-up menu.
It is implemented by adding the following immediately before the second-to-last “
if value of (pop up button 1 of window 1) is "None" then click pop up button 1 of window 1 -- The "Signature" Pop-up click menu item 3 of menu 1 of pop up button 1 of window 1 -- The first signature in the list end if
Of course, one can always change “
menu item 3“ to read “
menu item ‘signature-name‘“, where “signature-name“ is the name of the signature you want to select, if you don’t want it to just pick the first out of the list. Hell, you can even modify it to pick a random signature if you want.
So, to be as clear as possible, the full, modifed, AppleScript is as follows:
tell application "Mail" to activate tell application "System Events" tell process "Mail" tell menu bar 1 click menu bar item "Message"'s menu "Message"'s menu item "Reply" end tell delay 0.5 key code 117 -- Forward Delete key code 125 using command down -- Down Arrow key code 36 -- Return if value of (pop up button 1 of window 1) is "None" then click pop up button 1 of window 1 -- The "Signature" Pop-up click menu item 3 of menu 1 of pop up button 1 of window 1 -- The first signature in the list end if end tell end tell
Thanks go out to John. Hopefully my modifications will be helpful to others too.
My apologies for the horrendously tiny font for my code blocks. I’ve had a redesign in the works for a while. The site redesign has now gone live, so the code font should be much more legible.
1 I guess you’d call it a set. It’s one script with instructions for the one word addition to make the second script.