Mail.app Script: Bottom Post

I’ve made peace with mostly top-posting my email replies in the name of efficiency.

But there are often times when I want to bottom-post my reply to address a specific section.

I finally broke down a wrote a script to automate the transformation of Mail.app’s top-post format to my preferred bottom-post format.

That is, it turns this:

|   

-jwr

On Nov 30, 2010, at 1:13 AM, Grumble Mumble wrote:

> we made some turkey and fixings...  time for christmas cookies...

into this:

On Nov 30, 2010, at 1:13 AM, Grumble Mumble wrote:
> we made some turkey and fixings...  time for christmas cookies...

|

-jwr

Where I denote the insertion point’s location with the pipe character.

The script assumes your .sig is one line and your reply message window is frontmost:

-- delay a second to give me time to release the
-- FastScript-invocation command key modifiers before
-- the script runs
delay 1
tell application "System Events"
    set downArrow to 125
    set upArrow to 126
    set backspace to (ASCII character 8)

    -- select first 4 lines
    key code upArrow using command down
    repeat 4 times
        key code downArrow using shift down
    end repeat

    -- move those 4 lines to the bottom
    keystroke "x" using command down
    key code downArrow using command down
    keystroke "v" using command down

    -- delete 2 trailing lines
    keystroke backspace
    keystroke backspace

    -- delete extra line between "On $DATE $SENDER wrote" and quote
    key code upArrow using command down
    key code downArrow
    keystroke backspace

    -- position insertion point to reply area, adding another line
    key code downArrow using command down
    key code upArrow
    key code upArrow
    keystroke (ASCII character 13)
end tell

It would be nice if I didn’t trash the clipboard’s contents when moving the top lines to the bottom, but I’m out of patience for this little project.

I’ve bound it to Command-Shift-Option-Down-Arrow using FastScripts.

Update: Apparently there’s a plugin for Mail.app for bottom posting: QuoteFix. Thanks to Caio Chassot and Peter Hosey.

mail.app applescript Nov 30 2010