title: Using AppleScript to reply to selected message in Mail
body: <p>First time poster and AppleScript newbie.</p>
  
  <p>I am trying to make an AppleScript which takes the selected mail in mail.app and opens a reply window. In short, I would like it to function exactly like pressing the "reply" button in the mail.app GUI: Open up a reply window and automatically fill the To, Subject, and Body fields.</p>
  
  <p>The closest I got was the following:</p>
  
  <pre><code>tell application "Mail"
  
      set theSelection to selection
      if theSelection is {} then return
      activate
  
      repeat with thisMessage in theSelection
          set theOutgoingMessage to reply thisMessage with opening window
      end repeat
  
  end tell
  </code></pre>
  
  <p>Unfortunately, what this does is create a new reply window for each message in the selected conversation. For example: if there are 4 messages in the conversation when I run this script, I get 4 separate reply windows.</p>
  
  <p>Even if I select only one message in the conversation (e.g., the top most message), the script still opens up 4 separate reply windows.</p>
  
  <p>I also tried the following, but nothing happens:</p>
  
  <pre><code>tell application "Mail"
  
      set theSelection to item 1 of selection
      if theSelection is {} then return
      activate
  
      set theOutgoingMessage to reply theSelection with opening window
  
  end tell
  </code></pre>
  
  <p>But this has no visible result (no window opens at all). Any help to point me in the right direction?</p>
  
  <p>.R</p>