Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5605)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 5620)
@@ -2717,4 +2717,8 @@
                 //Compatibilização com Outlook, ao encaminhar a mensagem
                 $body = mb_ereg_replace('<!--\[', '<!-- [', $params['body']);
+                $body = str_replace("%nbsp;","&nbsp;",$body);
+                $body = preg_replace("/\n/"," ",$body);
+                $body = preg_replace("/\r/","" ,$body);
+                $body = html_entity_decode ( $body, ENT_QUOTES , 'ISO-8859-1' );	
             }
 
@@ -2893,5 +2897,6 @@
                      else
                          $mailService->addStringAttachment(base64_decode($att['source']), $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' );
-
+                     
+                     $message_size_total += $att['size'];
                      unset($att);
                 }
@@ -2899,14 +2904,34 @@
                 {
                     $value = json_decode($value, true);
-                    $sub =  $value['name'] ? $value['name'].'.eml' :'no title.eml';
-                    $mbox_stream = $this->open_mbox($value['folder']);
-                    $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']);
-                    $mailService->addStringAttachment($rawmsg, $sub, 'message/rfc822', '7bit', 'attachment' );
-                    $message_size_total += mb_strlen($rawmsg); //Adiciona o tamanho do anexo a variavel que controlao tamanho da msg.
-                    unset($rawmsg);
+
+                    switch ($value['type']) {
+                        case 'imapPart':
+                                $att = $this->getForwardingAttachment($value['folder'],$value['uid'], $value['part']);
+                                if(strstr($body,'<img src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'" />') !== false)//Embeded IMG
+                                {    
+                                    $body = str_ireplace('<img src="./inc/get_archive.php?msgFolder='.$value['folder'].'&msgNumber='.$value['uid'].'&indexPart='.$value['part'].'" />' , '<img src="'.$att['name'].'" />', $body);
+                                    $mailService->addStringImage($att['source'], $att['type'], $att['name']);
+                                }
+                                else
+                                    $mailService->addStringAttachment($att['source'], $att['name'], $att['type'], 'base64', isset($att['disposition']) ? $att['disposition'] :'attachment' );
+                                 
+                                $message_size_total += $att['size']; //Adiciona o tamanho do anexo a variavel que controlao tamanho da msg.
+                                unset($att);
+                            break;
+                            case 'imapMSG':
+                                $sub =  $value['name'] ? $value['name'].'.eml' :'no title.eml';
+                                $mbox_stream = $this->open_mbox($value['folder']);
+                                $rawmsg = $this->getRawHeader($value['uid']) . "\r\n\r\n" . $this->getRawBody($value['uid']);
+                                $mailService->addStringAttachment($rawmsg, $sub, 'message/rfc822', '7bit', 'attachment' );
+                                $message_size_total += mb_strlen($rawmsg); //Adiciona o tamanho do anexo a variavel que controlao tamanho da msg.
+                                unset($rawmsg);
+                            break;
+
+                        default:
+                            break;
+                    }
                 }
-
             }
-
+	
             $message_size_total += strlen($params['body']);   /* Tamanho do corpo da mensagem. */        
 
@@ -3086,24 +3111,21 @@
 		return $bolean;
 	}
-
-	function get_forwarding_attachment($msg_folder, $msg_number, $msg_part, $encoding)
-	{
+        
+        function getForwardingAttachment($folder, $uid, $part, $rfc_822bodies = true , $info = true )
+        {
             include_once dirname(__FILE__).'/class.attachment.inc.php';
             $attachment = new attachment();
-			$attachment->decodeConf['rfc_822bodies'] = true; //Forçar a não decodificação de mensagens em anexo.
-            $attachment->setStructureFromMail($msg_folder, $msg_number);
-            return $attachment->getAttachment($msg_part);
-	}
-
-        function get_forwarding_attachment2($msg_folder, $msg_number, $msg_part, $encoding)
-	{
-            include_once dirname(__FILE__).'/class.attachment.inc.php';
-            $attachment = new attachment();
-            $attachment->setStructureFromMail($msg_folder, $msg_number);
-            $return = $attachment->getAttachmentInfo($msg_part);
-            $return['binary'] = $attachment->getAttachment($msg_part);
-            return $return;
-	}
-
+            $attachment->decodeConf['rfc_822bodies'] = $rfc_822bodies; //Forçar a não decodificação de mensagens em anexo.
+            $attachment->setStructureFromMail($folder, $uid);
+            
+            if($info === true)
+            {
+                $return = $attachment->getAttachmentInfo($part);
+                $return['source'] = $attachment->getAttachment($part);
+                return $return;
+            }
+            return $attachment->getAttachment($part);
+        }
+            
 	function del_last_caracter($string)
 	{
