Change Mail behavior when replying to a message in the Sent mailbox
Jun 09, '11 07:30:00AM • Contributed by: Anonymous

When using Gmail (I don't know if this is the case with other webmail providers), if you reply to a message in your Sent mailbox, the recipient of the reply message is set to the recipient of the original message you sent. That makes sense, it's useful for quickly replying to a message you've just sent when you realize you've forgotten something (like an attachment).

However, Apple Mail doesn't work that way; if you reply to a message in your Sent mailbox, you (the sender of the original message) become the recipient of the reply message (which is pretty useless in my opinion).

If you choose Reply all instead of Reply, it's a little better: you are still the 'To' recipient of the reply message, but the recipients of the original message are added as Cc: recipients of the reply message.

I used this fact to create an AppleScript that when invoked creates a reply to the selected message in the Sent mailbox in Mail, with the recipients of the original message as 'To' recipients of the reply message and no Cc: recipient, thus restoring Gmail's behavior in Mail.

Here is the script:

tell application "Mail"
activate
set theMessages to the selected messages of the front message viewer
(*the script is intended to work on only one message but if "selection" is used instead of "selected items" along with "first item of" on the next line, nothing happens (no message appears). I think it's a bug in the reply command. (A little Google search shows you this command has a buggy past...) *)
set theMessage to first item of theMessages
set outgoingReplyMessage to (reply theMessage with opening window and reply to all)
(*"reply to all" is always used in order to get the recipients of the original message in the Cc field (as I said above, if it's not used, the original recipients are not used anywhere). They are switched to the To field later on. *)
set theIntendedRecipientsAdresses to (get address of every cc recipient of outgoingReplyMessage)
set quoted to quote original message
if quoted is true then
set quote original message to false
(*this is to prevent the cited text of the original message to appear a large number of time in the reply message (in my tests, it was copied at least 27 times). I think this is another bug... *)
end if
repeat with theIntendedRecipientAddress in theIntendedRecipientsAdresses
(*this is the real work : each cc recipient is copied to the To recipient field. *)
tell outgoingReplyMessage
set theIntendedRecipient to make new to recipient at the end of to recipients
set address of theIntendedRecipient to theIntendedRecipientAddress
end tell
end repeat
set address of first to recipient of outgoingReplyMessage to ""
--deletes you (the sender) from the list of To recipients
set address of cc recipient of outgoingReplyMessage to ""
--deletes every Cc recipients
if quoted is true then
set quote original message to true
end if
end tell

For ease of use, I copied that script into a 'Run Applescript' Automator action (receive no input, in application Mail) and saved it as a Service (10.6 only). I then assigned a keyboard shortcut for it using the Keyboard preference pane of System Preference (Under the Keyboard Shortcut tab, then choosing Services on the left). Command+Option+Shift+R and Command+Control+Option+R are both available in Mail.

Of course, you can also use it with your favorite shortcut application, be it Quicksilver, Butler, Alfred, Keyboard Maestro, etc. Just save it as a Script instead (.scpt).

Be warned that this script is only intended to be used in the Sent mailbox; using it on a message in your Inbox won't work (and could lead to errors.) What's more, there is no error detection to verify it is used in the Sent mailbox.

[crarko adds: I tested this, and it works as described. A very useful script.]

Change Mail behavior when replying to a message in the Sent mailbox
Authored by: postglock on Jun 09, '11 05:07:29PM

Send again is slightly different, as it works as far as recipients are concerned, but doesn't indent the quote levels by one (which can be manually indented after selecting all via Format > Quote Level > Increase).

Change Mail behavior when replying to a message in the Sent mailbox
Authored by: glusk on Jun 09, '11 10:04:33AM

Nice script. I usually like to reply to myself instead of send again to make it clear that it's a new additional thought and not a mistake. This script does the things I've been doing by hand. Thanks!
I also have a smart mailbox in mail.app that includes Sent and Inbox to incorporate my own messages in the the threads. Wish iOS would do this.

Change Mail behavior when replying to a message in the Sent mailbox
Authored by: howiedi2 on Jun 09, '11 03:10:05PM

Why not just use the send again command (Shift-Command-D)? It re-sends the original message, keeping the original recipients intact, and allows you to append the message with extra text, and include an attachment. No need to overcomplicate this with a script.

When I need to add a thought or two to a message already sent I use the MailFollup plugin by Greg Welch. <code>http://www.cs.unc.edu/~welch/MailFollowup/</code> The term 'followup' clearly identifies such a message as an afterthought or added thought. Works well. Plays nice with Letterbox and MailTabs. (Caveat - I have no relationship with Greg Welch or the plugin beyond being a satisfied user.)

Setting aside the merits of the script, let's rewrite it in more sturdy fashion just for the exercise:

tell application "Mail"
try
set quoteOriginalMessagePref to quote original message
set selectedMsg to (get selected messages of some message viewer whose index is 1)'s 1st item
if selectedMsg's mailbox's name = "Sent Messages" then
tell selectedMsg
set recipientList to {name, address} of its recipients
set newOutgoingMessage to reply with opening window
end tell
delay 0.05 # This value might need adusting to allow the quoted material to show up.
if quoteOriginalMessagePref = true then set quote original message to false
tell newOutgoingMessage
set address of to recipients to ""
repeat with ndx from 1 to length of (item 1 of recipientList)
make new recipient at end of to recipients with properties ¬
{name:item ndx of item 1 of recipientList, address:item ndx of item 2 of recipientList}
end repeat
end tell
if quoteOriginalMessagePref then set quote original message to true
else
error "Selected Messages Not in 'Sent Messages' Mailbox"
end if
on error errMsg number errNum
try
set quote original message to quoteOriginalMessagePref
end try
set sep to "=============================="
set e to sep & return & "Error: " & errMsg & return & sep & return ¬
& "Error Number: " & errNum & return & sep
beep
display dialog e
end try
end tell

Kudos to the O.P. for figuring a way around Mail's evil multiple-quotation bug.

I prefer to run this sort of thing with FastScripts (a recent MacGem), because it handles app-specific keyboard shortcuts better than Mac OS X's service menu and has other useful features.