Index: sandbox/2.5.1-expresso1/prototype/modules/attach_message/attach_message.js
===================================================================
--- sandbox/2.5.1-expresso1/prototype/modules/attach_message/attach_message.js	(revision 7885)
+++ sandbox/2.5.1-expresso1/prototype/modules/attach_message/attach_message.js	(revision 7890)
@@ -384,5 +384,5 @@
 
                 expresso_mail_archive.getMessagesByFolder(targetId,"ALL");
-                 
+
                 msgAll = expresso_mail_archive.msgAll;                
 
@@ -391,7 +391,11 @@
                 var flag = '';
                 
-
                 $.each(msgAll, function(i, msg){
                     from = $.parseJSON(msg['_from']);
+
+                    if(!from){
+                        from = {"mailbox":{"name":"null","route":"null","localPart":"null","domain":"null"}};
+                    }
+
                     flag = $.parseJSON(msg['_tags']);
                     id = msg['_id'];
@@ -481,5 +485,5 @@
 				});
 				
-				// reconstrÃ³i a seleÃ§Ã£o das mensagens mesmo depois da mudanÃ§a de pasta
+				// reconstrói a seleção das mensagens mesmo depois da mudança de pasta
 				if (selectedMessages[selectedFolder.id]) {
 					for (var message in selectedMessages[selectedFolder.id]){
@@ -507,29 +511,29 @@
 				if (selected) {	
                    if(selectedFolder['id'].indexOf("local_messages_") != -1){
-                        // Arrumar isso!
-                        //tabPanelTemplateId - mailpreview_tab_INBOX_1110
-                        //tabPanelTemplateLabel - Re: asduiahdih
-                        console.log(tabPanelTemplateId);
-                        tabPanelTemplateLabel =  "Re: asduiahdih";
-
-                            expresso_mail_archive.getMessageInfo(id);
-                            expresso_mail_archive.getMessageBodies([id]);
-
-                                var body = expresso_mail_archive.bodyPreview;
-                                var subject = expresso_mail_archive.subjectPreview;
-
-                                $mailpreview_tabs.tabs("add", '#' + tabPanelTemplateId, tabPanelTemplateLabel)
-                                .find('.message.empty-container').hide().end()
-                                .find('#' + tabPanelTemplateId).html(body)
-                                .prepend(
-                                    '<div class="mailpreview-message-info">' + 
-                                        get_lang('Subject') + ': ' +
-                                        html_entities(subject) + 
-                                    '</div>'
-                                )
-                                .find('[class^="ExpressoCssWrapper"]').addClass("mailpreview-message-body");
-
+
+                        expresso_mail_archive.getPreviewToAttach(id);
+
+                        var body = expresso_mail_archive.bodyPreview;
+                        var subject = expresso_mail_archive.subjectPreview;
+                        tabPanelTemplateLabel =  subject.substring(0, $mailpreview_tabs_label_length) + '...';
+
+                        if (!$('#' + tabPanelTemplateId).length) {
+                            $mailpreview_tabs.tabs("add", '#' + tabPanelTemplateId, tabPanelTemplateLabel)
+                            .find('.message.empty-container').hide().end()
+                            .find('#' + tabPanelTemplateId).html(body)
+                            .prepend(
+                                '<div class="mailpreview-message-info">' + 
+                                    get_lang('Subject') + ': ' +
+                                    html_entities(subject) + 
+                                '</div>'
+                            )
+                            .find('[class^="ExpressoCssWrapper"]').addClass("mailpreview-message-body");
+                        } else {
+                            $mailpreview_tabs.tabs('select', '#' + tabPanelTemplateId)
+                            .find('#' + tabPanelTemplateId + ', [href="#' + tabPanelTemplateId + '"]').removeClass('preview-message-unselected');
                         }
+                    }
 					if (onceOpenedMessages[selectedFolder.id] && onceOpenedMessages[selectedFolder.id][message.msg_number]) {
+
 						if (!selectedMessages[selectedFolder.id])
 							selectedMessages[selectedFolder.id] = {};
@@ -542,5 +546,5 @@
 							tabPanelTemplateLabel = tabPanelTemplateLabel.substring(0, $mailpreview_tabs_label_length) + '...';
 						
-						if (!$('#' + tabPanelTemplateId).length) {								
+						if (!$('#' + tabPanelTemplateId).length) {
 							$mailpreview_tabs.tabs("add", '#' + tabPanelTemplateId, tabPanelTemplateLabel)
 							.find('.message.empty-container').hide().end()
