Announcement

Collapse
No announcement yet.

Send multiple attachments via email ? Formula

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

  • Send multiple attachments via email ? Formula

    Hello,

    I'm new to the forum. I've been trying to figure out how to send attachments via email, and I found that it works only for a single attachment using the "fileId" field. However, it doesn't seem to work for multiple attachments.​


    I tried that.

    PHP Code:

    $attachmentId 
    record\create('Attachment',
        
    'role''Attachment',
        
    'type'record\attribute('Attachment'picesJointesIds'type'),
        
    'size'record\attribute('Attachment'picesJointesIds'size'),
        
    'global'record\attribute('Attachment'picesJointesIds'global'),
        
    'name'record\attribute('Attachment'picesJointesIds'name'),
        
    'sourceId'picesJointesIds,
        
    'storage'record\attribute('Attachment'picesJointesIds'storage')
    );


    $id record\create(
        
    'Email',
        
    'from''test@test.com',
        
    'to'test,
        
    'subject'name,
        
    'body'rponses,
        
    'isHtml'true,
        
    'attachmentsIds', list($attachmentId),
        
    'status''Sending'
    );
    ext\email\send($id);​ 

  • #2
    Hi BigBoss,

    Please try using this formula script:
    Code:
    $i = 0;
    
    $attachmentsIds = list();
    
    while(
        
        $i < array\length(picesJointesIds),
        $picesJointesId = array\at(picesJointesIds, $i);
    
        $attachmentId = record\create('Attachment',
        'role', 'Attachment',
        'type', record\attribute('Attachment', $picesJointesId, 'type'),
        'size', record\attribute('Attachment', $picesJointesId, 'size'),
        'global', record\attribute('Attachment', $picesJointesId, 'global'),
        'name', record\attribute('Attachment', $picesJointesId, 'name'),
        'sourceId', $picesJointesId,
        'storage', record\attribute('Attachment', $picesJointesId, 'storage')
        );
            
        $attachmentsIds = array\push($attachmentsIds, $attachmentId);
    
        $i = $i + 1;
        
    );
    
    $emailId = record\create('Email',
               'to', 'your_email_address',
               'status', 'Draft',
               'attachmentsIds', $attachmentsIds
                );
    
    ext\email\send($emailId);​

    Comment


    • #3
      Here you have link to video with presentation how you can do that: How to send email with multiple attachments in EspoCRM - YouTube

      Comment

      Working...
      X