How to save sent messages in same folder as message being replied to? One of my favorite features back when I used Outlook was the option to save sent emails in the same folder as the message being replied to. For example, if I had moved a message to folder A and was replying to that, my reply was saved in A, not Sent. (If I replied to a message in my Inbox, my reply went to the default Sent folder.)

This made it really easy to see an entire thread when I came back to it later. This workflow is a huge time-saver for me and is the only thing I miss from Outlook. Right now, I manually move sent messages to the folder with related messages which is tedious. Is there a way to recreate this feature from Outlook with Mac Mail? (I'm using Mac Mail 6.2 on OSX 10.8.2).
Mail can be extended to mimic pretty closely the feature you mention from Outlook. 

OS X provides a feature called services that can be used to extend the functionality of an application (see http://www.macosxautomation.com/services/learn/index.html for more information). 

I will use Automator and AppleScript to create a service that moves sent messages to the folder of the message being replied to, and then assign the standard reply keyboard shortcut (⌘R) to the service:


Close Mail.
Open Automator in folder Applications and choose Service:





Select Utilities under Library and drag Run AppleScript to the empty pane on the right:





Configure the service to receive no input in Mail:





Replace the contents of the Run AppleScript action with:

on run {input, parameters}

tell application "Mail"
    try
        (* Get selected messages or exit *)
        set messageSelection to selection
        set selectedMessage to item 1 of messageSelection
        set replyMessage to reply selectedMessage opening window yes
        set messageID to message id of selectedMessage
        set currentMailbox to mailbox of selectedMessage
    on error
        return
    end try
    repeat
        (* Wait until reply message is sent *)
        delay 2
        try
            if replyMessage is not visible then exit repeat
        on error
            exit repeat
        end try
    end repeat
    synchronize with (account of currentMailbox)
    (* Wait while reply message is being sent *)
    delay 10
    (* Loop over all sent messages *)
    set sentMailbox to sent mailbox of application "Mail"
    set allSentMessages to messages of sentMailbox
    repeat with sentMessage in allSentMessages
        if source of sentMessage contains messageID then
            set mailbox of sentMessage to currentMailbox
            return
        end if
    end repeat
end tell

return input
end run



Save with a descriptive name like Reply and Move Sent Message to Current Folder. The service will be saved to ~/Library/Services/. This is what the service looks like:






Open System Preferences, select the Keyboard preference pane and then the Keyboard Shortcuts tab.
Select Application Shortcuts, press the + button and change for application Mail the shortcut assigned to menu item Reply to ⌥⌘R. We change it to avoid conflicts when assigning ⌘R to the service below:





Select Services, scroll down to the service you previously added and set the keyboard shortcut to ⌘R:





Open Mail. Notice that Reply's shortcut is no longer ⌘R, but ⌥⌘R:





Also notice that there is a new service, accessible with ⌘R:





Now select a message in a folder, press ⌘R, type your reply and send it, in a few seconds you should see the sent message appear in the folder.


The script has some limitations and side effects:


The service can't tell canceled and sent messages apart. So, if you press ⌘R and then change your mind and close the window, the service will continue executing and check your Sent folder for matching IDs.
AppleScript doesn't offer any means of getting a list of replies to a message. My workaround is to get the message id of the message being replied to and search it in the sent messages.
The sent message can't be moved while being downloaded. AppleScript doesn't return any error message if that's the case, so I added a 10-second delay. A 5-second delay was not reliable in my tests, adapt it to your needs if necessary.
While the service searches the Sent folder, Mail slows down.