AnsweredAssumed Answered

Add parent to email generated with MailerFactory

Question asked by Francesca Shiekh on Oct 10, 2019
Latest reply on Oct 11, 2019 by André Lopes

I am using MailerFactory to programmatically send emails from a Case.

When the email is sent and the record created, I want to relate the Case to the Email (I have the case id).

 

There is probably a parameter I can use in the MailerFactory to give the specifics for the emails_beans table to be populated, but I can't find it.

This is the part of my custom function that sends the email:

 

    if (filter_var($to_addr, FILTER_VALIDATE_EMAIL)){
      try{
        $phpMailer = MailerFactory::getSystemDefaultMailer();
        $mailTransmissionProtocol = $phpMailer->getMailTransmissionProtocol();
        $FromEmailIdentity = new EmailIdentity($FromEmailAdd, $FromEmailName);
        $header_array = array(
          'From'=>$FromEmailIdentity,
          'ReplyTo'=>'',
          'Sender'=>$FromEmailIdentity, //mandatory
          'Subject'=>$EmailSubject,
        );
        $phpMailer->constructHeaders($header_array);
        $phpMailer->addRecipientsTo(new EmailIdentity($to_addr, $to_addr));
        $phpMailer->setHtmlBody($EmailBody);
        $phpMailer->send();
      }catch(MailerException $me) {
        $message = $me->getMessage();
        $GLOBALS["log"]->warn(
          "SendGroupEmail: error sending e-mail (method: {$mailTransmissionProtocol}), (error: {$message})"
        );
      }
    }

 

thanks,
Francesca

André Lopes can you help?

Outcomes