attach attachment to outgoing email

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
sticcino
User
Posts: 1043

attach attachment to outgoing email

Post by sticcino »

where can you hook into the current object to attach an attachment for the current email message? v2019.

on a view form that we want to send a message and also include the file associated with the record, there is no place to do the $email->AddAttachment(), it seems the only place to do this is in the exportEmail() function... which will be overwritten if you regen.

the email_Sending event is too late.


mobhar
User
Posts: 11729

Post by mobhar »

It actually depends on your needs; in which event did you want to send an email with the attachment files?


sticcino
User
Posts: 1043

Post by sticcino »

pretty simple setup:

have table assess_docs - holds, job no, filename, filepath,type, size etc... for each file associated with a job

from the assess_docs view/preview page user selects "view dolcument"

from the view page is where I have the email button enabled, so it simply sends the current record info/file. when the email form displays and you press send -- there is no place to modify the $email object before it is sent.
In the classes/xxxdocuments_view.php file in the exportEmail() function, i hacked it to include the attachment

// Export email
protected function exportEmail($emailContent)
{
  
     // temp fix....
    $attach_file = $this->document_path->CurrentValue. PATH_DELIMITER.$this->document->CurrentValue; // attach the requested file
    $email->addAttachment($attach_file);
  }

from a view form, there doesn't appear to be a way to get at the exportEmail() $email object to make changes if needed that I can see


mobhar
User
Posts: 11729

Post by mobhar »

Export Email is not the right one to send an attachment file, since it is intended for sending the exported record via email. You should use Email_Sending server event or SendEmail global function as possible.


sticcino
User
Posts: 1043

Post by sticcino »

that's where i had It, but it wasn't attaching the file.

I tried again, and it appears to be sending from the emailing event

thanks.


Post Reply