Announcement

Collapse
No announcement yet.

Multiple Files from different Entitys in Mail

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple Files from different Entitys in Mail

    Hello everyone,
    I have an entity named Projects that is connected to Employee Entities, each with one .docx attachment. (Screenshot)

    Now i need to send an E-Mail with all of the Employee .docx files as attachments.

    Can this be done with a Formula or Workflow and how?

    Thanks and regards,
    Niclas

  • #2
    Hi,

    You can do it using formula, if you wish yo can create a workflow and add condition and triggers and add Script Task to send email using formula, see example of code below (code below use Formula to send the contact an email documents attached to the contact, same thing could be done for your entities:

    Code:
    $documentId = record\findRelatedOne('Contact', id, 'documents', 'createdAt', 'desc');
    
    $documentName = record\attribute('Document', $documentId, 'name');
    
    $fileId = record\attribute('Document', $documentId, 'fileId');
    
    $attachmentId = record\create('Attachment',
    'role', 'Attachment',
    'type', record\attribute('Attachment', $fileId, 'type'),
    'size', record\attribute('Attachment', $fileId, 'size'),
    'global', record\attribute('Attachment', $fileId, 'global'),
    'name', record\attribute('Attachment', $fileId, 'name'),
    'sourceId', $fileId,
    'storage', record\attribute('Attachment', $fileId, 'storage')
    );
    
    $emailBody = string\concatenate(
    'Please find attached required document: ', $documentName, '<br> Cheers');
    
    $emailId = record\create(
    'Email',
    'to', entity\attribute('emailAddress'),
    'subject', 'Required Document',
    'body', $emailBody,
    'isHtml', true,
    'status', 'Sending',
    'attachmentsIds', list($attachmentId),
    'parentId', id,
    'parentType', 'Contact'
    );
    
    ext\email\send($emailId);
    Good luck and hope this helps
    Rabii
    Web Dev | Freelancer

    Comment

    Working...
    X