Index: trunk/expressoMail1_2/setup/tables_current.inc.php
===================================================================
--- trunk/expressoMail1_2/setup/tables_current.inc.php	(revision 2)
+++ trunk/expressoMail1_2/setup/tables_current.inc.php	(revision 413)
@@ -9,5 +9,5 @@
 	*  option) any later version.																						 *
 	\**************************************************************************/
-
+/*
 	$phpgw_baseline = array(
 		'phpgw_expressoMail_serverconfig' => array(
@@ -34,3 +34,4 @@
 		)
 	);
+*/
 ?>
Index: trunk/expressoMail1_2/setup/tables_update.inc.php
===================================================================
--- trunk/expressoMail1_2/setup/tables_update.inc.php	(revision 413)
+++ trunk/expressoMail1_2/setup/tables_update.inc.php	(revision 413)
@@ -0,0 +1,82 @@
+<?php
+	/**************************************************************************\
+	* phpGroupWare - Setup                                                     *
+	* http://www.phpgroupware.org                                              *
+	* --------------------------------------------                             *
+	* This program is free software; you can redistribute it and/or modify it  *
+	* under the terms of the GNU General Public License as published by the    *
+	* Free Software Foundation; either version 2 of the License, or (at your   *
+	* option) any later version.                                               *
+	\**************************************************************************/	
+	$test[] = '1.230';
+	function expressoMail1_2_upgrade1_230() {
+		global $setup_info, $phpgw_setup;
+	$phpgw_setup->oProc->CreateTable('phpgw_expressomail_contacts',array(
+			'fd' => array(
+				'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
+				'data' => array( 'type' => 'text')
+			),
+			'pk' => array('id_owner'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+		)
+	);
+	$setup_info['expressoMail1_2']['currentver'] = '1_231';
+		return $setup_info['expressoMail1_2']['currentver'];
+	}
+	
+	$test[] = '1.222';
+	function expressoMail1_2_upgrade1_222() {
+		global $setup_info, $phpgw_setup;
+	$phpgw_setup->oProc->CreateTable('phpgw_expressomail_contacts',array(
+			'fd' => array(
+				'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
+				'data' => array( 'type' => 'text')
+			),
+			'pk' => array('id_owner'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+		)
+	);
+	$setup_info['expressoMail1_2']['currentver'] = '1_231';
+		return $setup_info['expressoMail1_2']['currentver'];
+	}
+	
+	$test[] = '1.2211';
+	function expressoMail1_2_upgrade1_2211() {
+		global $setup_info, $phpgw_setup;
+	$phpgw_setup->oProc->CreateTable('phpgw_expressomail_contacts',array(
+			'fd' => array(
+				'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
+				'data' => array( 'type' => 'text')
+			),
+			'pk' => array('id_owner'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+		)
+	);
+	$setup_info['expressoMail1_2']['currentver'] = '1_231';
+		return $setup_info['expressoMail1_2']['currentver'];
+		
+	}
+	$test[] = '1.2031';
+	function expressoMail1_2_upgrade1_2031() {
+		global $setup_info, $phpgw_setup;
+	$phpgw_setup->oProc->CreateTable('phpgw_expressomail_contacts',array(
+			'fd' => array(
+				'id_owner' => array( 'type' => 'int', 'precision' => 8, 'nullable' => false),
+				'data' => array( 'type' => 'text')
+			),
+			'pk' => array('id_owner'),
+			'fk' => array(),
+			'ix' => array(),
+			'uc' => array()
+		)
+	);
+	$setup_info['expressoMail1_2']['currentver'] = '1_231';
+		return $setup_info['expressoMail1_2']['currentver'];
+	}
+?>
Index: trunk/expressoMail1_2/setup/setup.inc.php
===================================================================
--- trunk/expressoMail1_2/setup/setup.inc.php	(revision 381)
+++ trunk/expressoMail1_2/setup/setup.inc.php	(revision 413)
@@ -17,4 +17,5 @@
 //	$setup_info['expressoMail1_2']['tables'][]    	= 'phpgw_expressoMail1_2_apps';
 //	$setup_info['expressoMail1_2']['tables'][]		= 'phpgw_expressoMail1_2_log';
+	$setup_info['expressoMail1_2']['tables'][]		= 'phpgw_expressomail_contacts';
 	$setup_info['expressoMail1_2']['enable']    	= 1;
 
Index: trunk/expressoMail1_2/preferences.php
===================================================================
--- trunk/expressoMail1_2/preferences.php	(revision 389)
+++ trunk/expressoMail1_2/preferences.php	(revision 413)
@@ -50,4 +50,17 @@
 			$GLOBALS['phpgw']->template->set_var('checked_mainscreen_showmail','');
 
+		if (!is_numeric($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_Number_of_dynamic_contacts'])) 
+		{										
+			$GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','');
+			$GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','disabled');
+		}
+		else
+		{
+			if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'])
+				$GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','checked');
+			else
+				$GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','');
+		}
+
 		if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'])
 			$GLOBALS['phpgw']->template->set_var('checked_shortcuts','checked');
@@ -147,4 +160,24 @@
 		else
 			$GLOBALS['phpgw']->preferences->add('expressoMail','mainscreen_showmail',$_POST['mainscreen_showmail']);
+
+		if (!is_numeric($_SESSION['phpgw_info']['server']['expressomail']['expressoMail_Number_of_dynamic_contacts'])) 
+		{										
+			$GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','');
+			$GLOBALS['phpgw']->template->set_var('checked_dynamic_contacts','disabled');
+		}
+		else
+		{
+			if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'])
+			{
+				$GLOBALS['phpgw']->preferences->change('expressoMail','use_dynamic_contacts',$_POST['use_dynamic_contacts']);
+				if($_POST['use_dynamic_contacts'] == '')
+				{
+					$contacts = CreateObject('expressoMail1_2.dynamic_contacts');
+					$contacts->delete_dynamic_contacts();
+				}
+			}
+			else
+			$GLOBALS['phpgw']->preferences->add('expressoMail','use_dynamic_contacts',$_POST['use_dynamic_contacts']);
+		}
 
 		if ($GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'])
@@ -220,4 +253,5 @@
 	$GLOBALS['phpgw']->template->set_var('lang_line_height',lang('What is the height of the lines in the list of messages?'));
 	$GLOBALS['phpgw']->template->set_var('lang_font_size',lang('What the font size in the list of messages?'));
+	$GLOBALS['phpgw']->template->set_var('lang_use_dynamic_contacts',lang('Use dynamic contacts?'));
 	$GLOBALS['phpgw']->template->set_var('lang_use_shortcuts',lang('Use shortcuts?'));
 	$GLOBALS['phpgw']->template->set_var('lang_auto_save_draft',lang('Auto save draft'));
Index: trunk/expressoMail1_2/inc/class.db_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 205)
+++ trunk/expressoMail1_2/inc/class.db_functions.inc.php	(revision 413)
@@ -3,5 +3,6 @@
 define('PHPGW_API_INC','../phpgwapi/inc');	
 include_once(PHPGW_API_INC.'/class.db.inc.php');
-	
+include_once('class.dynamic_contacts.inc.php');
+
 class db_functions
 {	
@@ -142,8 +143,11 @@
 	}
 
-	function get_dropdown_contacts(){
+	function get_dropdown_contacts()
+	{
+		$dynamic_contact = new dynamic_contacts();
 		
 		$contacts = $this -> get_cc_contacts();
 		$groups = $this -> get_cc_groups();
+		$dynamic = $dynamic_contact->dynamic_contact_toString();
 		
 		if(($contacts) && ($groups))
@@ -155,5 +159,10 @@
 		elseif ((!$contacts) && ($groups))
 			$stringDropDownContacts = $groups;
-					
+		if (($dynamic) && (($groups) || ($contacts)))
+			$stringDropDownContacts .= ',' . $dynamic;
+		else 
+			if ($dynamic)
+				$stringDropDownContacts = $dynamic;
+				
 		return $stringDropDownContacts;	
 	}
@@ -257,4 +266,60 @@
 		return $result;
 	}
+	
+	function get_dynamic_contacts()
+	{				
+		// Pesquisa os emails e ultima inserção nos contatos dinamicos.
+ 		if(!$this->db->select('phpgw_expressomail_contacts','data',
+						  'id_owner ='.$this -> user_id,
+						  __LINE__,__FILE__))
+		{
+        	return $this->db->Error;
+        }
+		while($this->db->next_record())
+		{
+			$result[] = $this->db->row();
+		}
+		foreach($result as $item) 
+		{
+			$contacts = unserialize($item['data']);
+		}
+		if (count($contacts) == 0)
+		{			
+			return null;
+		}	
+		return $contacts;
+	}
+	
+	function update_contacts($contacts=array())
+	{			
+		// Atualiza um email nos contatos dinamicos.
+		if(!$this->db->update('phpgw_expressomail_contacts ','data=\''.serialize($contacts).'\'',
+							  'id_owner ='.$this -> user_id,
+							  __LINE__,__FILE__))
+		{
+		  	return $this->db->Error;
+		}
+    	return $contacts;
+	}	
+	
+	function insert_contact($contact)	
+	{
+		$contacts[] = array( 'timestamp' 	=> time(),
+								'email'		=> $contact );
+
+		// Insere um email nos contatos dinamicos.	
+		$query = 'INSERT INTO phpgw_expressomail_contacts (data, id_owner)  ' .
+					'values ( \''.serialize($contacts).'\', '.$this->user_id.')';
+		
+		if(!$this->db->query($query,__LINE__,__FILE__))
+    	  	return $this->db->Error;
+    	return $contacts;
+	}
+	
+	function remove_dynamic_contact($user_id,$line,$file)
+	{
+		$where = $user_id.' = id_owner';
+		$this->db->delete('phpgw_expressomail_contacts',$where,$line,$file);	
+	}
 }
 ?>
Index: trunk/expressoMail1_2/inc/class.imap_functions.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 411)
+++ trunk/expressoMail1_2/inc/class.imap_functions.inc.php	(revision 413)
@@ -1246,4 +1246,9 @@
 				$sent = trim($sent);									   			
    				error_log("$now - $userip - $sent [$subject] - $userid => $addrs\r\n", 3, "/home/expressolivre/mail_senders.log");
+			}
+			if($_SESSION['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'])
+			{
+				$contacts = new dynamic_contacts();
+				$contacts->add_dynamic_contacts($toaddress.$ccaddress.$ccoaddress);
 			}
    			return true;
Index: trunk/expressoMail1_2/inc/class.dynamic_contacts.inc.php
===================================================================
--- trunk/expressoMail1_2/inc/class.dynamic_contacts.inc.php	(revision 413)
+++ trunk/expressoMail1_2/inc/class.dynamic_contacts.inc.php	(revision 413)
@@ -0,0 +1,200 @@
+<?php
+/**********************************************************************************\
+	* ExpressoMail1_2                 										   *
+	* by Gustavo Sandini Linden (gustavo.linden@serpro.gov.br)						   *
+	* ---------------------------------------------------------------------------------*
+	*  This program is free software; you can redistribute it and/or modify it         *
+	*  under the terms of the GNU General Public License as published by the           *
+	*  Free Software Foundation; either version 2 of the License, or (at your          *
+	*  option) any later version.											           *
+	\**********************************************************************************/
+	
+$GLOBALS['phpgw_info']['flags'] = array(
+		'currentapp' => 'expressoMail1_2',
+		'noheader'   => True, 
+		'nonavbar'   => True,
+		'enable_nextmatchs_class' => True
+	);
+
+include('../header.inc.php');
+include_once('class.db_functions.inc.php');
+include_once('class.functions.inc.php');
+	
+	/**
+	 * dynamic_contacts - User's dynamic contact class
+	 * @package dynamic_contacts
+	 * @author Gustavo S. Linden
+	 * @copyright 2008 - Gustavo S. Linden
+	 * 
+	 * TODO: Check if email already exists in contactcenter!!
+	 * 
+	 */	
+	class dynamic_contacts
+	{
+		public $contacts;
+		public $db;
+		public $number_of_contacts;
+		public $functions; 
+		
+		/**
+     	* Constructor
+     	* 
+       	*/
+		function __construct()
+		{
+			$this->db = new db_functions();
+			$this->contacts = $this->db->get_dynamic_contacts();
+			$this->number_of_contacts = $_SESSION['phpgw_info']['server']['expressomail']['expressoMail_Number_of_dynamic_contacts'];
+			$this->functions = new functions();
+		}
+		
+		/**
+		* get dynamic contacts
+		*
+		* @return array $contacts The list of fields to be returned. The format is:
+				$contacts = array(
+					'timestamp' => '1220558565',
+					'email => 'some@email'
+				);
+		*/
+		function get_dynamic_contacts()
+		{
+			return $this->contacts;  
+		}
+		
+		/**
+		* get number of contacts
+		*
+		* @return int $number_of_contacts 
+		* maximum number of contact allowed by administration
+		* if not set return undefined  
+		*/
+		function get_number_of_contacts()
+		{
+			return $this->number_of_contacts;  
+		}
+	
+		/**
+		* get dynamic contacts in string format
+		*
+		* @return string $contact of contacts in format ';some@email,;other@email,'
+		* this is used in js/DropDownContacts.js  
+		*/
+		function dynamic_contact_toString()
+		{
+			$contact='';
+			if($this->contacts)
+			{
+				foreach($this->contacts as $item => $valor)
+					$contact .= ';'.$this->contacts[$item]['email'] . ',';
+				//Retira ultima virgula.
+				$contact = substr($contact,0,(strlen($contact) - 1));
+				return $contact;
+			}
+			else
+				return false;
+		}
+		
+		/**
+		* add dynamic contacts in database
+		*
+		* this function runs thru the array and check if the email sent has new contacts
+		* or not. If the contact is new, insert new array $contact in array $contacts else
+		* search existing contact to update timestamp. 
+		*
+		* @param string $full_email_address to add eg. 'some@address,other@email,email@address' 
+		* @return array $contacts The list of fields to be returned. The format is:
+				$contacts = array(
+					'timestamp' => '1220558565',
+					'email => 'some@email'
+				);
+		* this is used in inc/class.db_function.inc.php to insert/update in database  
+		*/
+		function add_dynamic_contacts($full_email_address)
+		{
+			$parse_address = imap_rfc822_parse_adrlist($full_email_address, "");
+			foreach ($parse_address as $val)
+			{
+				if ($val->mailbox == "INVALID_ADDRESS")
+					continue;
+				if ($this->contact_exist_in_ContactCenter($val->mailbox."@".$val->host))
+					continue;
+					
+				if(!$this->contacts) // Used one time to insert the first contact in database
+				{
+					$this->db->insert_contact($val->mailbox."@".$val->host);
+					$this->contacts = $this->db->get_dynamic_contacts();
+				}
+				else
+				{
+					$older_contact_time=time();
+					$new_contact_flag = true; // Assume that all email are new in dynamic contact
+					foreach($this->contacts as $item => $valor)
+					{
+						if($this->contacts[$item]['email'] == $val->mailbox."@".$val->host) // check if email already exists
+						{	
+							$this->contacts[$item]['timestamp'] = time(); //update timestamp of email
+							$new_contact_flag = false; //email exist!
+						}
+						if($this->contacts[$item]['timestamp'] < $older_contact_time) //search for oldest email
+							{
+								$older_contact = $item; 
+								$older_contact_time = $this->contacts[$item]['timestamp'];
+							}
+					}
+					if ($new_contact_flag == true) //new contact!
+					{
+						if($this->number_of_contacts > count($this->contacts))
+						{
+							$this->contacts[] = array( 'timestamp'	=> time(),
+														'email'		=> $val->mailbox."@".$val->host);
+						}
+						if($this->number_of_contacts <= count($this->contacts))
+						{
+							$this->contacts[$older_contact] = array( 'timestamp'	=> time(),
+																		'email'		=> $val->mailbox."@".$val->host);
+						}
+					}
+				}
+			}
+			$this->db->update_contacts($this->contacts);
+		}
+		
+		/**
+		* Verify if contact exist in ContactCenter
+		*
+		* this function gets an email and check if the email sent is already on users's personal contacts
+		* or not.  
+		*
+		* @param string $full_email_address to add eg. 'some@address,other@email,email@address' 
+		* @return boolean  
+		*/
+		function contact_exist_in_ContactCenter($email)
+		{
+			$contactcenter_string = $this->db->get_cc_contacts();
+			$cc_email = explode(",",$contactcenter_string);
+			foreach ($cc_email as $item => $valor) 
+			{
+				$aux = explode(";",$cc_email[$item]);
+				if($email == $aux[1])
+				{
+					return true;	
+				}
+				  
+			}
+			return false;
+		}
+		
+		/**
+		* delete dynamic contacts from database
+		*
+		* This function removes the dynamic contacts of the current user from the database.
+		* It uses inc/class.db_function.inc.php to remove.
+		*
+		*/
+		function delete_dynamic_contacts()
+		{
+			$this->db->remove_dynamic_contact($this->db->user_id,__LINE__,__FILE__);
+		}
+	}
+?>
Index: trunk/expressoMail1_2/js/main.js
===================================================================
--- trunk/expressoMail1_2/js/main.js	(revision 389)
+++ trunk/expressoMail1_2/js/main.js	(revision 413)
@@ -856,6 +856,8 @@
 			write_msg(get_lang('Your message was sent and save.'));
 			wfolders.alert = false;
+			init();
 		}else{
-			write_msg(get_lang('Your message was sent.'));		
+			write_msg(get_lang('Your message was sent.'));
+			init();		
 		}
 		if ((! newMessageTab.toPreserve[ID]) && (newMessageTab.imapUid[ID] != 0))
Index: trunk/expressoMail1_2/js/DropDownContacts.js
===================================================================
--- trunk/expressoMail1_2/js/DropDownContacts.js	(revision 376)
+++ trunk/expressoMail1_2/js/DropDownContacts.js	(revision 413)
@@ -59,5 +59,8 @@
 				tmp[1] = tmp[1].replace(tmp_mail, tmp_mail.bold());
 				tmp[0] = tmp[0].replace(tmp_mail, tmp_mail.bold());
-				match_contacts[match_index] = '&quot;' + tmp[0] + '&quot; &lt;' + tmp[1] + '&gt;';
+				if(tmp[0] == '')
+					match_contacts[match_index] = tmp[0] + ' &lt;' + tmp[1] + '&gt;';
+				else
+					match_contacts[match_index] = '$&quot;' + tmp[0] + '&quot; &lt;' + tmp[1] + '&gt;';
 				match_index++;
 			}
Index: trunk/expressoMail1_2/js/preferences.js
===================================================================
--- trunk/expressoMail1_2/js/preferences.js	(revision 340)
+++ trunk/expressoMail1_2/js/preferences.js	(revision 413)
@@ -73,8 +73,10 @@
 				"<option value='15'>"+get_lang("Big")+"</option>"+
 				"</select></td></tr>"+
+				"<tr><td> - " + get_lang("Use dynamic contacts?") + "</td>"+
+				"<td><input type='checkBox' id='use_dynamic_contacts' name='use_dynamic_contacts'></td></tr>"+
+				"<tr><td> - " + get_lang("Use shortcuts?") + "</td>"+
+				"<td><input type='checkBox' id='use_shortcuts' name='use_shortcuts'></td></tr>"+
 				"<tr><td> - " + get_lang("Auto save draft") + "?</td>"+
 				"<td><input type='checkBox' id='auto_save_draft' name='auto_save_draft'></td></tr>"+
-				"<tr><td> - " + get_lang("Use shortcuts?") + "</td>"+
-				"<td><input type='checkBox' id='use_shortcuts' name='use_shortcuts'></td></tr>"+
 				"<tr><td nowrap> - " + get_lang('Insert signature automatically in new messages?') + "</td>"+
 				"<td><input type='checkBox' id='use_signature' name='use_signature'></td>"+
@@ -140,4 +142,8 @@
 				if(sel_size_font.options[i].value == preferences.font_size){sel_size_font.options[i].selected = true;}
 			}
+		var use_dynamic_contacts = Element("use_dynamic_contacts");
+			if (preferences.use_dynamic_contacts == 1) {
+				use_dynamic_contacts.checked = true;
+			}
 		var use_signature = Element("use_signature");
 			if( preferences.use_signature == 1){
@@ -147,4 +153,9 @@
 			txt_signature.value = preferences.signature;
 		
+		if ((_this.number_of_contacts < 1) || isNaN(_this.number_of_contacts)) 
+		{
+			Element("use_dynamic_contacts").checked = false;
+			Element("use_dynamic_contacts").disabled = 'disabled';
+		}
 		if( preferences.use_shortcuts == 1) Element("use_shortcuts").checked = true;
 		if( preferences.auto_save_draft == 1) Element("auto_save_draft").checked = true;
@@ -154,6 +165,7 @@
 	// Salva as opções do form;
 	Preferences.prototype.save_form = function(){
-	
-	   //var prefe_string;			
+		
+		var _this = this;	
+	    //var prefe_string;			
 		var reload_page = false;
 
@@ -172,4 +184,9 @@
 	    else if(preferences.auto_save_draft != Element("auto_save_draft").checked)
 			reload_page = true;
+		else if(preferences.use_dynamic_contacts != Element("use_dynamic_contacts").checked)
+		{
+			reload_page = true;
+			_this.delete_dynamic_contacts();
+		}
 				
 		preferences.max_email_per_page = Element("sel_num_max").value; 
@@ -185,9 +202,9 @@
 		preferences.use_signature = Element("use_signature").checked ? 1 : 0;
 		preferences.signature = Element("txt_signature").value;
+		preferences.use_dynamic_contacts = Element("use_dynamic_contacts").checked ? 1 : 0;
 		preferences.use_shortcuts = Element("use_shortcuts").checked ? 1 : 0;
 		preferences.auto_save_draft = Element("auto_save_draft").checked ? 1 : 0;
-		
-		var _this = this;
-		
+
+
 	   	var handler_preferences = function(data){
 	   		if(data && data.success){
@@ -234,4 +251,5 @@
 		document.getElementById("use_signature").checked = false;		
 		document.getElementById('txt_signature').value = "";
+		document.getElementById("use_dynamic_contacts").checked = false;
 	}
 
@@ -246,5 +264,5 @@
 			div.style.paddingLeft = "10px";			
 			var title = get_lang("ExpressoMail 1.2 Configuration");
-			var wHeight = "420px";
+			var wHeight = "480px";
 			var wWidth =  "530px";
 
@@ -270,5 +288,22 @@
 		win.open();
 	}
+	
+	Preferences.prototype.delete_dynamic_contacts = function(){
+		var handler = function(data){}
+		var args   = "$this.dynamic_contacts.delete_dynamic_contacts";
+		var params = "";
+		cExecute(args,handler,params);
+	}
+	Preferences.prototype.get_number_of_contacts = function(){
+		var _this = this;
+		var handler = function(data){
+			_this.number_of_contacts = data;
+		}
+		var args   = "$this.dynamic_contacts.get_number_of_contacts";
+		var params = "";
+		cExecute(args,handler,params);
+	}
 // Cria o objeto	
 	var prefe;
 	prefe = new Preferences();
+	prefe.get_number_of_contacts();
Index: trunk/expressoMail1_2/index.php
===================================================================
--- trunk/expressoMail1_2/index.php	(revision 395)
+++ trunk/expressoMail1_2/index.php	(revision 413)
@@ -82,5 +82,6 @@
     		'font_size' 						=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['font_size'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['font_size'] : "11",
     		'use_shortcuts' 					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_shortcuts'] : "0",
-    		'auto_save_draft'					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] : "0"
+    		'auto_save_draft'					=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['auto_save_draft'] : "0",
+   			'use_dynamic_contacts' 				=> $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] ? $GLOBALS['phpgw_info']['user']['preferences']['expressoMail']['use_dynamic_contacts'] : "0"
     		
 	);
@@ -126,4 +127,6 @@
 	// End Set Anti-Spam options.
 
+	// Dynamic contact.
+	$_SESSION['phpgw_info']['server']['expressomail']['expressoMail_Number_of_dynamic_contacts'] = $current_config['expressoMail_Number_of_dynamic_contacts'];
 
        // Set Imap Folder names options
Index: trunk/expressoMail1_2/templates/default/preferences.tpl
===================================================================
--- trunk/expressoMail1_2/templates/default/preferences.tpl	(revision 389)
+++ trunk/expressoMail1_2/templates/default/preferences.tpl	(revision 413)
@@ -90,4 +90,10 @@
     </tr>
     <tr bgcolor="{tr_color1}">
+        <td>{lang_use_dynamic_contacts}</td>
+        <td align="center">
+			<input type="checkbox" name="use_dynamic_contacts" value=1 {checked_dynamic_contacts}>
+        </td>
+    </tr>
+    <tr bgcolor="{tr_color2}">
         <td>
 			{lang_use_shortcuts}
@@ -98,5 +104,5 @@
     </tr>
 
-    <tr bgcolor="{tr_color2}">
+    <tr bgcolor="{tr_color1}">
         <td>
 			{lang_auto_save_draft}
Index: trunk/expressoMail1_2/templates/default/config.tpl
===================================================================
--- trunk/expressoMail1_2/templates/default/config.tpl	(revision 197)
+++ trunk/expressoMail1_2/templates/default/config.tpl	(revision 413)
@@ -42,4 +42,10 @@
     </td>
    </tr>
+   <tr bgcolor="{row_on}">
+    <td>{lang_Number_of_dynamic_contacts}</td>
+    <td>
+	<input size="1" name="newsettings[expressoMail_Number_of_dynamic_contacts]" value="{value_expressoMail_Number_of_dynamic_contacts}"> 
+    </td>
+   </tr>
 <!-- END body -->
 <!-- BEGIN footer -->
