Announcement

Collapse
No announcement yet.

Send email to a list of email addresses

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

  • Send email to a list of email addresses

    Hi everyone,

    I am trying to create a workflow to send email to multiple email addresses (To and CC) when a Case status is changed.
    Since the Send Message Task in workflow does not have CC functions, I used formula instead. Below formula gave me a list of email addresses that needed to send email

    Click image for larger version  Name:	image.png Views:	0 Size:	37.2 KB ID:	86778

    The email will be sent to those email addresses plus CC email address that user fill in 'Description' field. For example:

    Click image for larger version  Name:	image.png Views:	0 Size:	19.7 KB ID:	86779

    ​I utilize below formula but the email does not send at all, can someone please help me to verify if email can be sent to an array?


    Click image for larger version  Name:	image.png Views:	0 Size:	35.0 KB ID:	86780



  • #2
    Hi Danny

    You are missing a status on your email it should be as below:

    Code:
    $emailId = record\create(
    'Email',
    'to', $emailids,
    'status', 'Sending',
    'subject', 'Your subject',
    'body', 'Content of your email body goes here',
    'isHtml', false
    );
    
    ext\email\send($emailId);
    without status => 'Sending' the email won't be sent.
    Thanks​
    Rabii
    Web Dev

    Comment


    • #3
      PLease note that the function doesn't support sending email to multiple contacts (array of contact email addresses at once). Maybe when you loop through the contacts just send email on each iteration.
      Rabii
      Web Dev

      Comment


      • #4
        Originally posted by rabii View Post
        PLease note that the function doesn't support sending email to multiple contacts (array of contact email addresses at once). Maybe when you loop through the contacts just send email on each iteration.
        Thank you, Rabi. I will look into your suggestion ^^

        Comment


        • #5
          Hey Danny

          Sorry my mistake, it is possible to send email to multiple emails at once, for example sending an email to multiple contacts of a Case entity, you can loops through the contacts get their email addresses and then send the email using the formula function like below:

          PHP Code:
          $i 0;
          $emails = list();

          while(
          $i array\length(contactsIds),
          (
          $emails array\push(
          $emails,
          record\attribute('Contact'array\at(contactsIds$i), 'emailAddress')
          );
          $i $i 1;
          )
          );

          $emailId record\create(
          'Email',
          'toEmailAddresses'$emails,
          'bcc''me@example.com',
          'status''Sending',
          'body''Body of your email',
          'isHtml'true,
          'parentId'entity\attribute('id'),
          'parentType''Case'
          );

          ext\email\send($emailId);​ 
          You can use also email template when sending email and even you can pass in variables as a placeholder.

          Hope this helps
          Rabii
          Web Dev

          Comment

          Working...
          X