thank you for sharing
I think we've published video about sending emails with attachments 
How to send email with multiple attachments in EspoCRM - YouTube
I think we've published video about sending emails with attachments 
// Case.attachments is a field of type Attachment Multiple. Get the first one from the array attachmentsIds.
$attachmentId = array\at(attachmentsIds, 0);
// Clone it
$clonedAttachmentId = record\create('Attachment',
'role', 'Attachment',
'type', record\attribute('Attachment', $attachmentId, 'type'),
'size', record\attribute('Attachment', $attachmentId, 'size'),
'global', record\attribute('Attachment', $attachmentId, 'global'),
'name', record\attribute('Attachment', $attachmentId, 'name'),
'sourceId', $attachmentId,
'storage', record\attribute('Attachment', $attachmentId, 'storage')
);
// Get all Case.contacts emailAddress's
// Case.contacts field is Link Multiple. Attribute: contactsIds is array of id's.
$i = 0;
$toStr= '';
while (
$i < array\length(contactsIds),
(
$Id = array\at(contactsIds, $i);
$emailAddr = record\attribute('Contact', $Id, 'emailAddress');
ifThen(
$i > 0,
$toStr=string\concatenate($toStr, ';')
);
$toStr=string\concatenate($toStr, $emailAddr);
$i = $i + 1;
)
);
$subject= 'subject placeholder';
$body= 'body placeholder';
$emailId = record\create(
'Email',
'from', 'accounting@mydomain.com',
'to', $toStr,
'subject', $subject,
'body', $body,
'isHtml', true,
'status', 'Sending',
'attachmentsIds', list($clonedAttachmentId),
'parentId', id,
'parentType', 'Case'
);
// Note, when using a template, the following parameters do not need to be defined: 'subject', 'body', 'is Html'
// Make sure Placeholders are appropriate for Case entity.
ext\email\applyTemplate($emailId, '655aaea4d69a3d4e4');
// Send the email
ext\email\send($emailId);
Leave a comment: