Index: /trunk/expressoMail1_2/js/main.js
===================================================================
--- /trunk/expressoMail1_2/js/main.js	(revision 7877)
+++ /trunk/expressoMail1_2/js/main.js	(revision 7899)
@@ -5379,5 +5379,12 @@
             if(data.append == 1)
             {
-                proxy_mensagens.get_msg(data.msg_number,data.msg_folder,false,show_msg,false);
+                proxy_mensagens.get_msg(data.msg_number,data.msg_folder,false,function (data) {
+                    if (onceOpenedHeadersMessages[data.msg_folder] == undefined) 
+                    {
+                        onceOpenedHeadersMessages[data.msg_folder] = [];
+                    };
+                    onceOpenedHeadersMessages[data.msg_folder][data.msg_number] = data;
+                    show_msg(data);
+                },false);
                 partMsgs.push(data.msg_number);
 	}
Index: /trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- /trunk/expressoMail1_2/js/draw_api.js	(revision 7897)
+++ /trunk/expressoMail1_2/js/draw_api.js	(revision 7899)
@@ -4758,105 +4758,88 @@
 */ 
 function attach_message (folder_name, message_number) { 
-
-    // Callback para caso seja necessário a mensagem não esteja no cache.
-    var handler_attach_message = function (message) {
-        var ID = currentTab; 
-        var fileUploadMSG = $('#fileupload_msg'+ID); 
-        fileUploadMSG.find(' .attachments-list').show(); 
-        var att = new Object(); 
-        att.folder = folder_name; 
-        att.uid = message_number; 
-        att.type = 'imapMSG'; 
-        att.name = Base64.encode(message.subject + '.eml'); 
-        var idATT = JSON.stringify(att); 
-        addAttachment(ID, idATT); 
-        var attach = {}; 
-        attach.fileName = message.subject + '.eml'; 
-        attach.fullFileName = message.subject + '.eml'; 
-        if(attach.fileName.length > 20)  
+    var ID = currentTab; 
+    var fileUploadMSG = $('#fileupload_msg'+ID); 
+    fileUploadMSG.find(' .attachments-list').show(); 
+    var att = new Object(); 
+    att.folder = folder_name; 
+    att.uid = message_number; 
+    att.type = 'imapMSG'; 
+    att.name = Base64.encode(onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml'); 
+    var idATT = JSON.stringify(att); 
+    addAttachment(ID, idATT); 
+    var attach = {}; 
+    attach.fileName = onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml'; 
+    attach.fullFileName = onceOpenedHeadersMessages[folder_name][message_number].subject + '.eml'; 
+    if(attach.fileName.length > 20)  
+    { 
+        attach.fileName = attach.fileName.substr(0, 17) + "... " + attach.fileName.substr(attach.fileName.length - 9, attach.fileName.length); 
+    } 
+ 
+    attach.error = false; 
+    attach.OK = true; 
+    attach.fileSize = formatBytes(onceOpenedHeadersMessages[folder_name][message_number].Size); 
+    var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", { 
+        file: attach 
+    })); 
+    $("#content_id_" + currentTab + " .save").button("enable"); 
+    upload.find('.att-box-loading').remove(); 
+    upload.append('<input type="hidden" name="fileId[]" value=\'' + idATT + '\'/>'); 
+ 
+    upload.find('.att-box-delete').click(function() 
+    { 
+        $("#content_id_" + currentTab + " .save").button("enable"); 
+        var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
+        fileUploadMSG.find(' .attachments-list').find('input[value="' + idAttach + '"]').remove(); 
+        delAttachment(ID, idAttach); 
+        $(this).parent().qtip("destroy"); 
+        $(this).parent().remove(); 
+        if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length) 
         { 
-            attach.fileName = attach.fileName.substr(0, 17) + "... " + attach.fileName.substr(attach.fileName.length - 9, attach.fileName.length); 
+            fileUploadMSG.find(' .attachments-list').hide(); 
         } 
-     
-        attach.error = false; 
-        attach.OK = true; 
-        attach.fileSize = formatBytes(message.Size); 
-        var upload = $(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", { 
-            file: attach 
-        })); 
-        $("#content_id_" + currentTab + " .save").button("enable"); 
-        upload.find('.att-box-loading').remove(); 
-        upload.append('<input type="hidden" name="fileId[]" value=\'' + idATT + '\'/>'); 
-     
-        upload.find('.att-box-delete').click(function() 
-        { 
-            $("#content_id_" + currentTab + " .save").button("enable"); 
-            var idAttach = $(this).parent().find('input[name="fileId[]"]').val(); 
-            fileUploadMSG.find(' .attachments-list').find('input[value="' + idAttach + '"]').remove(); 
-            delAttachment(ID, idAttach); 
-            $(this).parent().qtip("destroy"); 
-            $(this).parent().remove(); 
-            if(!fileUploadMSG.find(' .attachments-list').find(".att-box").length) 
-            { 
-                fileUploadMSG.find(' .attachments-list').hide(); 
+    }); 
+ 
+    fileUploadMSG.find('.attachments-list').append(upload); 
+ 
+    upload.find('.att-box-loading').remove(); 
+ 
+    fileUploadMSG.find('.attachments-list .att-box:last').qtip( 
+    { 
+        content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", { 
+            attach: attach 
+        }), 
+        position: { 
+            corner: { 
+                tooltip: 'bottomMiddle', 
+                target: 'topMiddle' 
+            }, 
+            adjust: { 
+                resize: true, 
+                scroll: true 
             } 
-        }); 
-     
-        fileUploadMSG.find('.attachments-list').append(upload); 
-     
-        upload.find('.att-box-loading').remove(); 
-     
-        fileUploadMSG.find('.attachments-list .att-box:last').qtip( 
-        { 
-            content: DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist_tooltip.ejs", { 
-                attach: attach 
-            }), 
-            position: { 
-                corner: { 
-                    tooltip: 'bottomMiddle', 
-                    target: 'topMiddle' 
-                }, 
-                adjust: { 
-                    resize: true, 
-                    scroll: true 
-                } 
+        }, 
+        show: { 
+            when: 'mouseover', 
+            // Don't specify a show event 
+            ready: false // Show the tooltip when ready 
+        }, 
+        hide: 'mouseout', 
+        // Don't specify a hide event 
+        style: { 
+            border: { 
+                width: 1, 
+                radius: 5 
             }, 
-            show: { 
-                when: 'mouseover', 
-                // Don't specify a show event 
-                ready: false // Show the tooltip when ready 
+            width: { 
+                min: 75, 
+                max: 1000 
             }, 
-            hide: 'mouseout', 
-            // Don't specify a hide event 
-            style: { 
-                border: { 
-                    width: 1, 
-                    radius: 5 
-                }, 
-                width: { 
-                    min: 75, 
-                    max: 1000 
-                }, 
-                padding: 5, 
-                textAlign: 'center', 
-                tip: true, 
-                // Give it a speech bubble tip with automatic corner detection 
-                name: 'blue' // Style it according to the preset 'cream' style 
-            } 
-        }); 
-    }
-
-    /* Substituída a variável onceOpenedMessages por onceOpenedHeadersMessages, 
-       porque essa última contem as mesmas informações da primeira, e está em escopo global.*/ 
-
-    // Caso a mensagem ainda não esteja no cache:
-    if ((onceOpenedHeadersMessages[folder_name] === undefined) || (onceOpenedHeadersMessages[folder_name][message_number] === undefined))
-    {
-        proxy_mensagens.get_msg(message_number, folder_name, '', function (data) { handler_attach_message(data); });
-    } else 
-    {
-        handler_attach_message(onceOpenedHeadersMessages[folder_name][message_number]);
-    }
-
+            padding: 5, 
+            textAlign: 'center', 
+            tip: true, 
+            // Give it a speech bubble tip with automatic corner detection 
+            name: 'blue' // Style it according to the preset 'cream' style 
+        } 
+    }); 
 }
 		
