diff --git a/privatemsg.install b/privatemsg.install
index ed83c20..cbd8f49 100644
--- a/privatemsg.install
+++ b/privatemsg.install
@@ -108,6 +108,13 @@ function privatemsg_schema() {
         'unsigned'      => TRUE,
         'default'       => 0,
       ),
+      'reply_to_mid' => array(
+        'description'   => 'mid of the message this is a reply to (if any)',
+        'type'          => 'int',
+        'default'       => 0,
+        'not null'      => TRUE,
+        'unsigned'      => TRUE,
+      )
     ),
     'primary key'     => array('mid'),
   );
@@ -336,3 +343,18 @@ function privatemsg_update_7006() {
   variable_set("date_format_privatemsg_current_year", 'M j');
   variable_set("date_format_privatemsg_years", 'n/j/y');
 }
+
+/**
+ * Add field to track what message this is a reply to (if any.)
+ */
+function privatemsg_update_7200() {
+  db_add_field('pm_message', 'reply_to_mid',
+    array(
+      'description'   => 'mid of the message this is a reply to (if any)',
+      'type'          => 'int',
+      'default'       => 0,
+      'not null'      => TRUE,
+      'unsigned'      => TRUE,
+    )
+  );
+}
diff --git a/privatemsg.module b/privatemsg.module
index d8286f6..6be09c2 100644
--- a/privatemsg.module
+++ b/privatemsg.module
@@ -1656,6 +1656,10 @@ function privatemsg_reply($thread_id, $body, $options = array()) {
     );
   }
 
+  // Add the reply_to_mid, so we can mark that message as replied
+  $thread = privatemsg_thread_load($thread_id);
+  $message->reply_to_mid = end($thread['messages'])->mid;
+
   $message->thread_id = $thread_id;
   // Load participants
   $message->recipients = _privatemsg_load_thread_participants($thread_id, $message->author);
@@ -1667,6 +1671,7 @@ function privatemsg_reply($thread_id, $body, $options = array()) {
       _privatemsg_handle_recipients($validated['message']->mid, $validated['message']->recipients, FALSE);
     }
   }
+
   return $validated;
 }
 
@@ -1807,6 +1812,10 @@ function _privatemsg_send($message) {
     $args['format'] = $message->format;
     $args['timestamp'] = $message->timestamp;
     $args['has_tokens'] = (int)$message->has_tokens;
+    if (isset($message->reply_to_mid)) {
+      $args['reply_to_mid'] = $message->reply_to_mid;
+    }
+    
     $mid = db_insert('pm_message')
       ->fields($args)
       ->execute();
diff --git a/privatemsg.pages.inc b/privatemsg.pages.inc
index 243e5d9..a5521de 100644
--- a/privatemsg.pages.inc
+++ b/privatemsg.pages.inc
@@ -394,6 +394,13 @@ function privatemsg_form_reply($form, &$form_state, $thread) {
     '#weight' => 20,
   );
 
+  // Include the mid of the message we're responding to so we can mark it as 
+  // replied when the form is submitted.
+  $reply_to_mid = end($thread['messages'])->mid;
+  $form['reply_to_mid'] = array(
+    '#type' => 'value',
+    '#value' => $reply_to_mid,    
+  );
   $form['thread_id'] = array(
     '#type' => 'value',
     '#value' => $thread['thread_id'],
diff --git a/privatemsg.test b/privatemsg.test
index bb8827e..525f43c 100644
--- a/privatemsg.test
+++ b/privatemsg.test
@@ -1305,7 +1305,6 @@ class PrivatemsgAPITestCase extends DrupalWebTestCase {
     $resultf2 = privatemsg_reply($thread_row->mid, 'Test Body', array('author' => $recipient3));
     $errormessage = t('@user is not allowed to write messages.', array('@user' => $recipient3->name));
     $this->assertEqual($errormessage, $resultf2['messages']['error'][0], 'API denied to send message from user without permission');
-
   }
 
   /**
