Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 4777)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 4781)
@@ -671,5 +671,5 @@
                                       $content .= $this->builderMsgHeader($part);
 
-                                   $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'])).'</pre>';
+                                   $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'],false)).'</pre>';
                                 }
 
@@ -696,5 +696,5 @@
                             {
                                 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
-                                $content .= '<pre>'. $this->decodeMailPart($part->body, $structure->ctype_parameters['charset']).'</pre>';
+                                $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body, $structure->ctype_parameters['charset'],false)).'</pre>';
                                 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
                             }
@@ -731,5 +731,5 @@
                                       $content .= $this->builderMsgHeader($part);
 
-                                   $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'])).'</pre>';
+                                   $content .= '<pre>'. htmlentities($this->decodeMailPart($part->body,$part->ctype_parameters['charset'],false)).'</pre>';
                                 }
 
@@ -750,5 +750,5 @@
                             {
                                 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
-                                $content .= '<pre>'.  htmlentities($this->decodeMailPart($part->body, $structure->ctype_parameters['charset'])).'</pre>';
+                                $content .= '<pre>'.  htmlentities($this->decodeMailPart($part->body, $structure->ctype_parameters['charset'],false)).'</pre>';
                                 $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
                             }
@@ -1093,4 +1093,26 @@
 	}
 
+	/* 
+ 	 * Converte textos utf8 para o padrão html. 
+ 	 * @link http://php.net/manual/en/function.utf8-decode.php 
+ 	 * @author luka8088 <luka8088@gmail.com> 
+ 	 */ 
+ 	function utf8_to_html ($data) 
+ 	{ 
+ 	    return preg_replace("/([\\xC0-\\xF7]{1,1}[\\x80-\\xBF]+)/e", '$this->_utf8_to_html("\\1")', $data); 
+ 	} 
+ 		 
+ 	function _utf8_to_html ($data) 
+ 	{ 
+ 	    $ret = 0; 
+		foreach((str_split(strrev(chr((ord($data{0}) % 252 % 248 % 240 % 224 % 192) + 128) . substr($data, 1)))) as $k => $v) 
+			$ret += (ord($v) % 128) * pow(64, $k); 
+ 		    return "&#$ret;"; 
+ 	} 
+ 	//------------------------------------------------------------------------------// 
+	
+	
+	
+	
 		/**
          * Decodifica uma part da mensagem para iso-8859-1
@@ -1099,5 +1121,5 @@
          * @return <type> string decodificada
          */
-        function decodeMailPart($part, $encode)
+        function decodeMailPart($part, $encode, $html = true)
         {
             switch (strtolower($encode))
@@ -1108,5 +1130,8 @@
 
                 case 'utf-8':
-                    return utf8_decode($part);
+                    if ($html) 
+						return  $this->utf8_to_html($part); 
+ 	                else       
+						return  utf8_decode ($part);
                     break;
 
@@ -1186,9 +1211,10 @@
                         if(($msg_subtype == "html" || $msg_subtype == 'plain') && ($disposition != 'attachment'))
                         {
-                                $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']) ;
+                                
 
                                 if(strtolower($msg_subtype) == 'plain')
                                 {
-                                        $content = str_replace(array('<', '>'), array(' #$<$# ', ' #$>$# '), $content);
+                                        $content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset'],false);
+										$content = str_replace(array('<', '>'), array(' #$<$# ', ' #$>$# '), $content);
                                         $content = htmlentities($content);
                                         $content = $this -> replace_links($content);
@@ -1198,4 +1224,5 @@
                                         return $return;
                                 }
+								$content = $this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']);
                         }
 
@@ -1211,5 +1238,5 @@
                     {
                         $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
-                        $content .= '<pre>'.$this->decodeMailPart($structure->body, $structure->ctype_parameters['charset']).'</pre>';
+                        $content .= '<pre>'.htmlentities($this->decodeMailPart($structure->body, $structure->ctype_parameters['charset'],false)).'</pre>';
                         $content .= "<hr align='left' width='95%' style='border:1px solid #DCDCDC'>";
                     }
