diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 117bfb13769..6c74c1ca612 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -845,6 +845,13 @@ class FormMail extends Form $out.= ''.$langs->trans("MailFile").''; $out.= ''; + + // If a template was selected, we use setup of template to define if join file checkbox is selected or not. + if (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) + { + $this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1); + } + if (! empty($this->withmaindocfile)) { if ($this->withmaindocfile == 1)