diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index bfa458eca45..7f2410da136 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -171,6 +171,7 @@ if (empty($reshook)) { dol_print_error($db); } + $thirdpartystatic = new Societe($db); // Loop on each email and send it $i = 0; @@ -200,6 +201,15 @@ if (empty($reshook)) { // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $substitutionarray['__ID__'] = $obj->source_id; + if ($obj->source_type == "thirdparty") { + $result = $thirdpartystatic->fetch($obj->source_id); + + if ($result > 0) { + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = $thirdpartystatic->code_client; + } else { + $substitutionarray['__THIRDPARTY_CUSTOMER_CODE__'] = ''; + } + } $substitutionarray['__EMAIL__'] = $obj->email; $substitutionarray['__LASTNAME__'] = $obj->lastname; $substitutionarray['__FIRSTNAME__'] = $obj->firstname; diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 80a9c75dffc..7ceca2f373b 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1569,6 +1569,7 @@ class FormMail extends Form // For mass emailing, we have different keys $tmparray['__ID__'] = 'IdRecord'; + $tmparray['__THIRDPARTY_CUSTOMER_CODE__'] = 'CustomerCode'; $tmparray['__EMAIL__'] = 'EMailRecipient'; $tmparray['__LASTNAME__'] = 'Lastname'; $tmparray['__FIRSTNAME__'] = 'Firstname';