To send an email with attachments stored in a database field, use the following code in events like BeforeAdd/AfterAdd/BeforeEdit/AfterEdit.
Make sure to replace "Field that stores attachments" with the actual field name. This must be a TEXT or VARCHAR(max) field that is set up as File/Image in PHPRunner.
Note: Attachments will only work when you selected "Use custom mailer server settings" under "Email settings".
$email= "test@gmail.com" ;
$msg="File Attached";
$subject="Attached some files";
$fileArray = my_json_decode($values["Field that stores attachments"]);
$attachments = array();
$msg = "";
foreach($fileArray as $f)
{
$attachments[] = array("path" => $f["name"]);
}
$msg.= "Some field: ".$values["Some field"]."\r";
$msg.= "Some other field: ".$values["Some other field"]."\r";
$ret=runner_mail(array('to' => $email, 'subject' => $subject, 'body' => $msg, "attachments" => $attachments));
if(!$ret["mailed"])
echo $ret["message"];
See also:
•How to email selected records as separate PDF files
•Send an email to selected users
•Send an email with updated fields only