diff --git a/admin/user/user_bulk_message.php b/admin/user/user_bulk_message.php
index a69546e..7f41333 100644
--- a/admin/user/user_bulk_message.php
+++ b/admin/user/user_bulk_message.php
@@ -30,7 +30,21 @@ if ($confirm and !empty($msg) and confirm_sesskey()) {
         //TODO we should probably support all text formats here or only FORMAT_MOODLE
         //For now bulk messaging is still using the html editor and its supplying html
         //so we have to use html format for it to be displayed correctly
-        message_post_message($USER, $user, $msg, FORMAT_HTML);
+
+            $patterns = array();
+            $replacement = array();
+            
+            //TODO: add support for first and last names - see MDL-20199
+            /* $patterns[]='##firstname##';
+            $replacement[]=fullname($user,'firstname');
+            $patterns[]='##lastname##';
+            $replacement[]=fullname($user,'lastname'); */
+            $patterns[]='##fullname##';
+            $replacement[]=fullname($user);
+            $patterns[]='##username##';
+            $replacement[]=$user->username;
+            $newmsg = str_ireplace($patterns,$replacement,$msg);
+            message_post_message($USER, $user, $newmsg, FORMAT_HTML, 'direct');
     }
     $rs->close();
     redirect($return);
diff --git a/user/messageselect.php b/user/messageselect.php
index d60fec1..27fc599 100644
--- a/user/messageselect.php
+++ b/user/messageselect.php
@@ -142,7 +142,14 @@ if (!empty($messagebody) && !$edit && !$deluser && ($preview || $send)) {
         } else if (!empty($send)) {
             $good = 1;
             foreach ($SESSION->emailto[$id] as $user) {
-                $good = $good && message_post_message($USER,$user,$messagebody,$format);
+            $patterns = array();
+            $replacement = array();
+            $patterns[]='##firstname##';
+            $replacement[]=$user->firstname;
+            $patterns[]='##lastname##';
+            $replacement[]=$user->lastname;
+            $newmsg = str_ireplace($patterns,$replacement,$messagebody);
+            $good = $good && message_post_message($USER,$user,$newmsg,$format);
             }
             if (!empty($good)) {
                 echo $OUTPUT->heading(get_string('messagedselectedusers'));
