diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 084747765125eec0a318080be21b1150472ded75..a815875dc52e32367c051624783a08b0e6a7c010 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -871,6 +871,7 @@ class FormMail extends Form
 		$resql = $this->db->query($sql);
 		if ($resql)
 		{
+			$num=$this->db->num_rows($resql);
 			$this->lines_model=array();
 			while ($obj = $this->db->fetch_object($resql))
 			{