I use this code to send email with attachment. on using multiple attachments it doesn’t work. can you help me please… how do i change the code?
function Email_Sending($email, &$args)
{
$sAFileName = $this->allegato->UploadPath."/" . $Args["rsnew"]["allegato"] ;
if (!empty($this->allegato->CurrentValue)){
$sAFileName = $this->allegato->UploadPath."/" . $this->allegato->CurrentValue;
} else {
$sAFileName = $this->allegato->UploadPath."/" . $Args["rsnew"]["allegato"] ;
}
$mail= $this->mailto->CurrentValue;
$email->Sender = "xxxx";
$email->Recipient = "xxx";
$email->Subject = "MODIFICA ESECUZIONE DISCIPLINARE"; // Change subject
$email->Content = "E' STATA MODIFICATA L'ESECUZIONE DISCIPLINARE. CONTROLLA L'ALLEGATO <BR><BR><B> NON RISPONDERE ALLA MAIL </B> ";
$email->Content .= " <br> Inserito da: ". CurrentUserName();
$email->Content .= " <br><br><br> Email generata automaticamente ";
$email->Format = "html";
$email->AddAttachment($sAFileName);
return true;
}
thanks for the help, now it works.
but if I use multiple attachments I don’t attach the files in the email.
I use Edit tag/File Upload/Multiple
For multiple attachments, then you may call addAttachment method for multiple times as the number of the uploaded files. That will add multiple attachments to that email.
i’m not very good with coding… help me please
// Email Sending event
function Email_Sending($email, &$args)
{
// $sAFileName = $this->allegato->UploadPath."/" . $args["rsnew"]["allegato"] ;
$myvalue= $args["rsold"]["allegato"];
if (!empty($myvalue)){
$sAFileName = $this->allegato->UploadPath."/" . $myvalue;
} else {
$sAFileName = $this->allegato->UploadPath."/" . $args["rsnew"]["allegato"] ;
}
//$mail= $this->mailto->CurrentValue;
$email->Sender = "xxxxxxxxxxx;
$email->Recipient = "xxxxxxxxxxxxxx";//$Args["rsnew"]["Email"];
$email->Subject = "MODIFICA ESECUZIONE DISCIPLINARE"; // Change subject
$email->Content = "E' STATA MODIFICATA L'ESECUZIONE DISCIPLINARE. CONTROLLA L'ALLEGATO <BR><BR><B> NON RISPONDERE ALLA MAIL </B> ";
$email->Content .= " <br> Inserito da: ". CurrentUserName();
$email->Content .= " <br><br><br> Email generata automaticamente ";
$email->Format = "html";
$email->addAttachment($sAFileName);
return true;
}
You should split each file from the multiple-files by using PHP explode , and then add each file by using addAttachment method that belongs to the $email object.
thank you, it work with php explode
Cat
December 27, 2023, 9:42pm
8
hello, good afternoonCould you show how the code turned out with php explode?