--- loncom/interface/lonmsg.pm	2006/12/06 23:44:33	1.189
+++ loncom/interface/lonmsg.pm	2006/12/13 01:45:15	1.190
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.189 2006/12/06 23:44:33 raeburn Exp $
+# $Id: lonmsg.pm,v 1.190 2006/12/13 01:45:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -379,24 +379,29 @@ sub store_instructor_comment {
 sub user_crit_msg_raw {
     my ($user,$domain,$subject,$message,$sendback,$toperm,$sentmessage)=@_;
 # Check if allowed missing
-    my $status='';
+    my ($status,$packed_message);
     my $msgid='undefined';
     unless (($message)&&($user)&&($domain)) { $status='empty'; };
     my $text=$message;
     my $homeserver=&Apache::lonnet::homeserver($user,$domain);
     if ($homeserver ne 'no_host') {
-       ($msgid,$message)=&packagemsg($subject,$message);
-       if ($sendback) { $message.='<sendback>true</sendback>'; }
+       ($msgid,$packed_message)=&packagemsg($subject,$message);
+       if ($sendback) { $packed_message.='<sendback>true</sendback>'; }
        $status=&Apache::lonnet::critical(
            'put:'.$domain.':'.$user.':critical:'.
            &escape($msgid).'='.
-           &escape($message),$homeserver);
+           &escape($packed_message),$homeserver);
         if (defined($sentmessage)) {
-            $$sentmessage = $message;
+            $$sentmessage = $packed_message;
         }
+        (undef,my $packed_message_no_citation) =
+            &packagemsg($subject,$message,undef,undef,undef,$user,$domain,
+                        $msgid);
+        $status .= &store_sent_mail($msgid,$packed_message_no_citation);
     } else {
        $status='no_host';
     }
+
 # Notifications
     my %userenv = &Apache::loncommon::getemails($user,$domain);
     if ($userenv{'critnotification'}) {
@@ -518,11 +523,9 @@ sub user_normal_msg_raw {
                (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
 		|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
 					    '/'.$env{'request.course.sec'})))) {
-           (undef, my $packed_message_no_citation)=
-                             &packagemsg($subject,$message,undef     ,$baseurl,
-                                          $attachmenturl,$user,$domain,$currid,
-                                                              undef,$crsmsgid);
-
+           (undef,my $packed_message_no_citation) =
+               &packagemsg($subject,$message,undef,$baseurl,$attachmenturl,
+                           $user,$domain,$currid,undef,$crsmsgid);
            $status .= &store_sent_mail($msgid,$packed_message_no_citation);
        }
     } else {