Index: trunk/expressoMail1_2/import.php
===================================================================
--- trunk/expressoMail1_2/import.php	(revision 615)
+++ trunk/expressoMail1_2/import.php	(revision 615)
@@ -0,0 +1,37 @@
+<?php
+	/**************************************************************************/
+	
+	$GLOBALS['phpgw_info']['flags'] = array(
+		'currentapp' => 'expressoMail1_2',
+		'noheader'   => True, 
+		'nonavbar'   => True,
+		'enable_nextmatchs_class' => True
+	);
+
+	include('../header.inc.php');
+	include('inc/class.imap_functions.inc.php');
+	
+
+	$GLOBALS['phpgw']->common->phpgw_header();
+	print parse_navbar();
+
+	$GLOBALS['phpgw']->template->set_file(array(
+		'expressoMail_import' => 'import.tpl'
+	));
+	
+	$GLOBALS['phpgw']->template->set_var('lang_import',lang('Import emails'));
+	$GLOBALS['phpgw']->template->set_var('lang_file',lang('zip mails to import'));
+
+	$GLOBALS['phpgw']->template->set_var('lang_save',lang('Save'));
+	$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
+	$GLOBALS['phpgw']->template->set_var('save_action',$GLOBALS['phpgw']->link('/index.php?menuaction=expressoMail1_2.imap_functions.import_msgs'));
+	$GLOBALS['phpgw']->template->set_var('th_bg',$GLOBALS['phpgw_info']["theme"][th_bg]);
+
+	$tr_color = $GLOBALS['phpgw']->nextmatchs->alternate_row_color($tr_color);
+	$GLOBALS['phpgw']->template->set_var('tr_color1',$GLOBALS['phpgw_info']['theme']['row_on']);
+	$GLOBALS['phpgw']->template->set_var('tr_color2',$GLOBALS['phpgw_info']['theme']['row_off']);
+
+	$GLOBALS['phpgw']->template->parse('out','expressoMail_import',True);
+	$GLOBALS['phpgw']->template->p('out');
+	$GLOBALS['phpgw']->common->phpgw_footer();
+?>
Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 614)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 615)
@@ -10,5 +10,6 @@
 		'get_range_msgs'				=> True,
 		'get_info_msg'					=> True,
-		'get_folders_list'				=> True
+		'get_folders_list'				=> True,
+		'import_msgs'					=> True
 	);
 
@@ -176,4 +177,66 @@
 		else
 			return $this->htmlspecialchars_encode($string);
+	}
+	/**
+	* Função que importa arquivos .eml exportados pelo expresso para a caixa do usuário. Testado apenas
+	* com .emls gerados pelo expresso, e o arquivo pode ser um zip contendo vários emls ou um .eml.
+	*/
+	function import_msgs() {
+		
+		if(!$this->mbox)
+			$this->mbox = $this->open_mbox($params["folder"]);
+		$errors = array();
+		$invalid_format = false;
+		$filename = $_FILES['arquivo']['name'];
+		if(substr($filename,strlen($filename)-4)==".zip") {
+			$zip = zip_open($_FILES['arquivo']['tmp_name']);
+
+			if ($zip) {
+				while ($zip_entry = zip_read($zip)) {
+					
+					if (zip_entry_open($zip, $zip_entry, "r")) {
+						$email = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
+						$status = @imap_append($this->mbox,
+								"{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"."INBOX",
+									$email
+									);
+						if(!$status)
+							array_push($errors,zip_entry_name($zip_entry));
+						zip_entry_close($zip_entry);
+					}
+				}
+
+			}
+
+			zip_close($zip);
+		}
+		else if(substr($filename,strlen($filename)-4)==".eml") {
+			$email = implode("",file($_FILES['arquivo']['tmp_name']));
+			$status = @imap_append($this->mbox,
+								"{".$this->imap_server.":".$this->imap_port.$this->imap_options."}"."INBOX",
+									$email
+									);
+			if(!$status)
+				array_push($errors,zip_entry_name($zip_entry));
+			zip_entry_close($zip_entry);
+		}
+		else 
+		{
+			echo "<script>alert(\"".lang("wrong file format")."\")</script>";
+			$invalid_format = true;
+		}
+		
+		if(!$invalid_format) {
+			if(count($errors)>0) {
+				$message = lang("fail in import:")."\n";
+				foreach($errors as $arquivo) {
+					$message.=$arquivo."\n";
+				}
+				echo "<script>alert(\"$message\")</script>";
+			}
+			else
+				echo "<script>alert(\"".lang("messages imported successfully")."\")</script>";
+		}
+		echo "<script>location.href='/expressoMail1_2/index.php'</script>";
 	}
 	
Index: trunk/expressoMail1_2/js/draw_api.js
===================================================================
--- trunk/expressoMail1_2/js/draw_api.js	(revision 614)
+++ trunk/expressoMail1_2/js/draw_api.js	(revision 615)
@@ -2337,5 +2337,6 @@
 		'<span title="'+get_lang("Move")+'" class="message_options" onclick=wfolders.makeWindow(\"\",\"move_to\")>'+get_lang("Move")+'</span> | '+
    		'<span title="'+get_lang("Print")+'" class="message_options" onclick=print_all()>'+get_lang("Print")+'</span> | '+
-	   	'<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span>';
+	   	'<span title="'+get_lang("Export")+'" class="message_options" onclick="export_all_selected_msgs()">'+get_lang("Export")+'</span> | ' + 
+		'<span title="'+get_lang("Import")+'" class="message_options" onclick="location.href=\'/expressoMail1_2/import.php\'">'+get_lang("Import")+'</span>';
 	
 	if (use_spam_filter) {
Index: trunk/expressoMail1_2/templates/default/import.tpl
===================================================================
--- trunk/expressoMail1_2/templates/default/import.tpl	(revision 615)
+++ trunk/expressoMail1_2/templates/default/import.tpl	(revision 615)
@@ -0,0 +1,30 @@
+
+<center>
+
+<table width="50%" border="0" cellspacing="2" cellpadding="2">
+
+<form method="POST" action="{save_action}" enctype="multipart/form-data">
+    <tr bgcolor="{th_bg}">
+        <td colspan="2" align="center">{lang_import}</td>
+    </tr>
+    <tr bgcolor="{tr_color1}">
+        <td>{lang_file}:</td>
+        <td align="center">
+			<input type="file" name="arquivo">
+        </td>
+    </tr>
+    <tr bgcolor="{th_bg}">
+    	<td colspan="2" >
+    		<table width="100%" border="0" cellspacing="2" cellpadding="2">
+    			<tr>
+        			<td align="left">
+        				<input type="button" name="cancel" value="{lang_cancel}" onClick="javascript:document.location.href = '../expressoMail1_2/index.php'">
+        			</td>
+        			<td align="right">
+        				<input type="submit" name="submit" value="{lang_save}">
+        			</td>        			
+        		</tr>
+        </td>        
+    </tr>
+</table>
+</center>
