diff --git a/sendmail/trunk/batch/batch_tools.php b/sendmail/trunk/batch/batch_tools.php
index 364f67e25e928402266377cb8925b029178264b4..6cb42e5d872fa1379c50f8e5f3964f3767590162 100644
--- a/sendmail/trunk/batch/batch_tools.php
+++ b/sendmail/trunk/batch/batch_tools.php
@@ -39,7 +39,8 @@
  */
 function Bt_doQuery($dbConn, $queryTxt, $param=array(), $transaction=false)
 {
-    $stmt = $dbConn->query($queryTxt, true);
+    $stmt = $dbConn->query($queryTxt, $param, true);
+    //$stmt = $dbConn->query($queryTxt);
     if (!$stmt) {
         if ($transaction) {
             $GLOBALS['logger']->write('ROLLBACK', 'INFO');
diff --git a/sendmail/trunk/batch/process_emails.php b/sendmail/trunk/batch/process_emails.php
index 6e191a779a9e8b964c64e7f99207d6502d5c2680..24d8e165361ab6b9a20ec47c414a07aa39b61af7 100644
--- a/sendmail/trunk/batch/process_emails.php
+++ b/sendmail/trunk/batch/process_emails.php
@@ -188,10 +188,10 @@ while ($state <> 'END') {
 			}
 			//Update emails table
 			$query = "UPDATE " . EMAILS_TABLE 
-				. " SET send_date = ? "
+				. " SET send_date = CURRENT_TIMESTAMP "
 				. ", email_status = ? "
 				. " WHERE email_id = ? ";
-			$stmt = Bt_doQuery($GLOBALS['db'], $query, array($GLOBALS['db']->current_datetime(), $exec_result, $email->email_id));
+			$stmt = Bt_doQuery($GLOBALS['db'], $query, array($exec_result, $email->email_id));
 			$currentEmail++;
 			$state = 'SEND_AN_EMAIL';
 		} else {
@@ -205,7 +205,7 @@ $GLOBALS['logger']->write('End of process', 'INFO');
 Bt_logInDataBase(
     $totalEmailsToProcess, 0, 'process without error'
 );
-$GLOBALS['db']->disconnect();
+
 //unlink($GLOBALS['lckFile']);
 exit($GLOBALS['exitCode']);
 ?>
diff --git a/sendmail/trunk/class/class_modules_tools.php b/sendmail/trunk/class/class_modules_tools.php
index 38560eb4a66d224df4f9e4fcdf5a7c4069037f92..fd1515df1a0ed29b3266432cef794eeb375987a0 100644
--- a/sendmail/trunk/class/class_modules_tools.php
+++ b/sendmail/trunk/class/class_modules_tools.php
@@ -281,18 +281,26 @@ class sendmail extends Database
         if (!empty($id)) {
 			$db = new Database();
             if ( $owner=== true) {
+				
                 $where = " and user_id = ? ";
                 $arrayPDO = array($_SESSION['user']['UserId']);
+                 $stmt = $db->query("select * from "
+                . EMAILS_TABLE 
+                . " where email_id = ? " . $where, array( $id, $_SESSION['user']['UserId']));
             } else {
                 $where = "";
+                $stmt = $db->query("select * from "
+                . EMAILS_TABLE 
+                . " where email_id = ? " . $where, array($id));
             }
-            
-            $stmt = $db->query("select * from "
+   
+            /*$stmt = $db->query("select * from "
                 . EMAILS_TABLE 
-                . " where email_id = ? " . $where, array_merge($arrayPDO, $id));
+                . " where email_id = ? " . $where, array_merge($arrayPDO, $id));*/
+               
             //
             if ($stmt->rowCount() > 0) {
-                $res = $tstmt->fetchObject();
+                $res = $stmt->fetchObject();
                 $email['id'] = $res->email_id;
                 $email['collId'] = $res->coll_id;
                 $email['resId'] = $res->res_id;