How can I attach email in history subpanel of contacts in Suite 8?

This code in not working

        $emailObj = new Email(); 
	$defaults = $emailObj->getSystemDefaultEmail(); 

	$mail = new SugarPHPMailer(); 
	$mail->setMailerForSystem(); 
	$mail->From = $defaults['email']; 
	$mail->FromName = $defaults['name']; 
	$mail->Subject = "Conferma presa in carico richiesta di finanziamento Pratica N ". $bean->numeropratica_c." Relativo a ".$bean->pratiche_name; 
	$mail->Body = $body;
        $mail->AddAttachment($dirAllegato . $bean->numeropratica_c.'.pdf', $bean->numeropratica_c, 'base64', 'application/pdf');
	$mail->isHTML(true);
	$mail->prepForOutbound();
	$mail->AddAddress('massimo.capuano.bari@gmail.com');
	$mail->Send();

Check your logs, especially php_errors.log

Thanks, @pgr for responding!
Can you please tell me what should I be looking for in the error logs?

Anything that looks like a clue, at the time your code runs.

You need to discover why it’s not working, and possibly the logs are telling you why.

1 Like