Index: branches/2.3/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- branches/2.3/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5873)
+++ branches/2.3/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 6264)
@@ -360,4 +360,5 @@
                     //reconstrói o email
                     $email = implode("", file($params['FILES'][0]['tmp_name']));
+                    $email = preg_replace('/(?<!\r)\n/', "\r\n", $email);
                     //coloca o email na pasta selecionada
                     $status = @imap_append($this->mbox, $folder, $email);
@@ -4180,4 +4181,6 @@
         $timestamps = explode("#@#@#@",$params['timestamp']);
         $flags = explode("#@#@#@",$params['flags']);
+        $ids = explode("#@#@#@",$params['id']);
+        $return = array(); 
 
         foreach($sources as $index=>$src)
@@ -4187,8 +4190,10 @@
 		$source = $this->treat_base64_from_post($src);
 		$insert = $this->insert_email($source,$dest_folder,$timestamps[$index],$flags[$index]);
+                if(!$insert['error'])
+                    $return[] = $ids[$index];
             }
 	}
         
-        return $insert;
+        return $return;
     }
 
Index: branches/2.3/expressoMail1_2/js/local_messages.js
===================================================================
--- branches/2.3/expressoMail1_2/js/local_messages.js	(revision 5040)
+++ branches/2.3/expressoMail1_2/js/local_messages.js	(revision 6264)
@@ -1239,8 +1239,10 @@
     var handler_unarchive = function(data)
     {
-		if(data.error == '')
-		    write_msg(get_lang('All messages are successfully unarchived'));
-		else
-		    alert(data.error);
+        if(preferences.keep_archived_messages == "0")
+             expresso_local_messages.delete_msgs(data.join());
+        if(currentTab != 0)
+            delete_border(currentTab,'false'); 
+        write_msg(get_lang('All messages are successfully unarchived'));
+
     }
 
@@ -1251,38 +1253,40 @@
     if(msgs_number =='selected' || !msgs_number)
     {
-		msgs_number = get_selected_messages()
-		if (!msgs_number){
-		    write_msg(get_lang('No selected message.'));
-		    return;
-		}
-		var rs = this.dbGears.execute("select mail,timestamp from mail where rowid in ("+msgs_number+")");
-		var source="";
-		var flags="";
-                var timestamp="";
-		
-		while(rs.isValidRow()) {
-			mail=connector.unserialize(rs.field(0));
-			mail.msg_source?source_tmp = escape(mail.msg_source):source_tmp = escape(this.get_src(mail.url_export_file));
-			flags+="#@#@#@"+mail["Answered"]+":"+mail["Draft"]+":"+mail["Flagged"]+":"+mail["Unseen"];
-                        source+="#@#@#@"+source_tmp;
-			timestamp+="#@#@#@"+rs.field(1);
-			rs.next();
-		}
-		rs.close();
-		this.finalize();
+        msgs_number = get_selected_messages()
+        if (!msgs_number){
+            write_msg(get_lang('No selected message.'));
+            return;
+        }
+        var rs = this.dbGears.execute("select mail,timestamp,rowid from mail where rowid in ("+msgs_number+")");
+        var source="";
+        var flags="";
+        var timestamp="";
+        var id="";
+
+        while(rs.isValidRow()) {
+                mail=connector.unserialize(rs.field(0));
+                mail.msg_source?source_tmp = escape(mail.msg_source):source_tmp = escape(this.get_src(mail.url_export_file));
+                    flags+="#@#@#@"+mail["Answered"]+":"+mail["Draft"]+":"+mail["Flagged"]+":"+mail["Unseen"];
+                    source+="#@#@#@"+source_tmp;
+                    timestamp+="#@#@#@"+rs.field(1);
+                    id+="#@#@#@"+rs.field(2);
+                rs.next();
+        }
+        rs.close();
+        this.finalize();
     }
     else
     {
-		var rs = this.dbGears.execute("select mail,timestamp from mail where rowid="+msgs_number);
-		mail=connector.unserialize(rs.field(0));
-		var source ="";
-
-		mail.msg_source?source = escape(mail.msg_source):source = escape(this.get_src(mail.url_export_file));
-		flags = mail["Answered"]+":"+mail["Draft"]+":"+mail["Flagged"]+":"+mail["Unseen"];
-		timestamp=rs.field(1);
-		rs.close();
-		this.finalize();
-    }
-    params="&folder="+new_folder+"&source="+source+"&timestamp="+timestamp+"&flags="+flags;
+        var rs = this.dbGears.execute("select mail,timestamp,rowid from mail where rowid="+msgs_number);
+        mail=connector.unserialize(rs.field(0));
+        var source ="";
+        mail.msg_source?source = escape(mail.msg_source):source = escape(this.get_src(mail.url_export_file));
+            flags = mail["Answered"]+":"+mail["Draft"]+":"+mail["Flagged"]+":"+mail["Unseen"];
+            timestamp=rs.field(1);
+            id=rs.field(2);
+            rs.close();
+        this.finalize();
+    }
+    params="&folder="+new_folder+"&source="+source+"&timestamp="+timestamp+"&flags="+flags+"&id="+id;
     cExecute ("$this.imap_functions.unarchive_mail&", handler_unarchive, params);
 }
