Announcement

Collapse
No announcement yet.

How to BCC email multiple accounts entities from formula?

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

  • How to BCC email multiple accounts entities from formula?

    I am a little stuck with flowcharts, everything is working perfect until I need to send an email to multiple accounts entities that are related to main entity, the problem is if I use the Send Email Task, I can only email using the To but this is including everyone's email rather than sending the email to each account without sharing others emails, I assume the best way to do this is using BBC but this is not visible on the Email Task form (don't understand why not).

    The only other option I guess is to use formula but this doesn't seem to like it when I use "record\findRelatedMany".

    this is what I am trying at the moment
    $ids = record\findRelatedMany('Notification', $noteid, 'accounts', 1000, 'createdAt', 'desc');

    $emailId = record\create(
    'Email',
    'from', $sender,
    'to', 'test@test.com',
    'cc', 'test@test.com',
    'bcc', 'teams@stylisticdesign.com',
    'subject', $alert,
    'isHtml', true,
    'status', 'Sending',
    'parentId', $noteid,
    'parentType', 'Account'
    );
    ext\email\applyTemplate($emailId, '62a413ec9c4831379');
    ext\email\send($emailId);

    Is this the correct way or should I be using something that converts the ID's to emails and if so what should I use?

    Other option is make the BCC drop down show on the Email Task in flowcharts but no idea where that is

  • #2
    Could not find the correct answer for this, so ended up doing the following

    Use the formula to create a list, create a template and create MassEmail record, then related all those together.

    $emailtemplate = record\create('EmailTemplate', 'name', $name, 'subject', $name, 'oneoff', 1, 'body', $emailBody);

    $targetlist = record\create('TargetList', 'name', $name);

    $massemail = record\create('MassEmail', 'name', $name, 'status', 'Pending', 'targetList', $targetlist, 'optOutEntirely', 1, 'emailTemplate', '62a413ec9c4831379', 'storeSentEmails', 1, 'fromAddress', $assignedUserEmail, 'replyToAddress', $assignedUserEmail, 'createdBy', $assigneduser);

    entity\addLinkMultipleId('massEmail', $targetlist);

    record\relate('TargetList', $targetlist, 'accounts', $accounts);

    record\relate('MassEmail', $massemail, 'targetLists', $targetlist);

    record\relate('MassEmail', $massemail, 'emailTemplate', $emailtemplate);

    Comment


    • #3
      you can try this https://docs.espocrm.com/administrat...ce-sub-process

      pass it the list of value and sent emails. Or use a loop on your formula to loop through the accounts and send email to each.
      Rabii
      Web Dev

      Comment

      Working...
      X