Introduction
In our last blog, we saw how we could create Power Automate Flow to send an email using the Email Template. We used “SendEmailFromTemplate” action to send a single email.
Now, in this blog, we will see how we can send bulk email messages using the Email Template.
Let us say, we want to send emails to reconnect with all our contacts in the system that we have not been in contact with for a while.
Below is how we can achieve this using the Power Automate. This could help you to create Power Automate Flow for your requirements where you may want to send bulk email messages.
Setup trigger for the Power Automate
For this example, I have used ‘Manually trigger a flow’ trigger.
Retrieve Email template
We will add ‘List Records’ step of Common Data Service Connector (Current) to retrieve the Email Template by its name (Title). We are retrieving the ‘Contact Reconnect’ template.
Add filter query to retrieve template by the title as shown below
This step will return the “Contact Reconnect” template. We will need this GUID of the template in the next step.
Retrieve records for which we want to send email
I am retrieving contacts from the system which I want to reconnect. We will add ‘List Records’ step and will retrieve contacts.
Initialize variable and store array of record’s GUID
As we want to send separate emails to each individual contact, we will first store GUID’s of each contact in an array variable.
First, initialize the array variable
Then, loop through all contacts retrieved in the above step and append GUID’s of each record to the array.
Retrieve Sender for the email
Sender of the email must be the user in the CDS environment. We will retrieve the System User record using ‘List Records’ step. We will use GUID of the user record in the next step.
Use ‘SendTemplate’ action
This ‘SendTemplate’ action is used to send bulk email messages using the Email Template. To execute this in Power Automate we need to add “Perform an unbound action” step.
This step requires below parameters,
Action Name: Select ‘SendTemplate’ from the list of actions.
TemplateId: GUID of the Email Template. In the second step, we retrieved the email template, we can use following expression to get the GUID of the template. first(body(‘GetEmailTemplate’)?[‘value’])?[‘templateid’]
Sender: Entity object of the user. Need to pass in the following format, systemusers(<guid of user>). To read the guid from the ‘List Records’ step, I can use following expression, first(body(‘GetSender’)?[‘value’])?[‘systemuserid’]
Recipients: Here we need to pass array of entity objects. I have passed the variable where I stored the list of entity objects of all the contacts. This parameter accepts value in the below format
Regarding: Record is to be set as the ‘Regarding’ of the email. In my example, setting the ‘Regarding’ does not make sense as I am not sending emails regarding any specific entity record. But, the problem is this parameter is required and it accepts entity object only. Here, I have passed the user entity object. As the user cannot be set as a ‘Regarding’, generated emails will not have regarding set.
This is all we required to send bulk email messages.
Now let us see what happens in the background. After we run the flow, a ‘Bulk Email’ system job gets created in the background. This job then creates and sends the email to all recipients separately. We can check the status in the system jobs as shown below
If you have added 5 records in the Recipients then 5 separate emails will get sent to them.
This is how we can send bulk email messages even for a large set of records.
Note: The SendTemplate action will not send emails to contact/account/lead if they opt-out for bulk email.
Conclusion
We can use Power Automate flow to send bulk email messages to a large set of recipients.
Automating repetitive processes has a multiplier effect on business productivity!
Power Apps helps expand automation capability to devices. Experts at Inogic- Professional Services assist organizations in implementing and maximizing value from PowerApps.
Write to us at crm@inogic.com for a techno-functional consultation and apt guidance
Can you please create a blog for Send an email using the GLOBAL Email Template with Power Automate?
Hi,
You can follow this blog for the GLOBAL email template as well. There is no difference in steps in sending email using Entity level and global Email Template.
Hope this helps!
Thanks.
I tried the same with Global Email Template, but receiving an error saying “Instantiate Email Template”.
I have even used the action “Instantiate Template” before using the action to send email. But I am still facing issues. Can you please help me?
Hi,
Check if you are able to manually create the same type of email using OOB Insert Template button. If you are able to create it then this might be a problem with the entity that you are using. Also, try using the same global template for OOB entity like Lead, Contact, etc.
Hope this helps,
Thanks!
Hi,
Quick question. How would you go about sending a non global template? When I try to use a email template created for cases it’s throwing a error saying “template.templatetypecode and not GlobalTemplate”.
Mike
Hi,
You can also send emails in bulk using non global template. We are able to send emails using email template created for case entity. We have followed the same steps given this blog and did following changes to send emails for case entity,
Retrieve email template created for the case entity.
Retrieve cases for which you want to send emails in bulk,
Set sender and regarding as the systemuser and recipients as the cases,
Hope this helps!
Thanks
Hi Mike,
Were you able to send non global email template later. Even me getting same error
Thanks very much for this really useful post.
As a note to others – make sure you implement the detail as described. In particular, having incorrect details in the SendTemplate unbound action can cause the GetEmailTemplate to fail.
Thanks! I’m using a global template and the email sends, with the template body, but the data references are not resolving. So, using your example, my email would say “Dear ,”. But when I use the Insert Template feature when creating an email activity on the same record, the values are populated properly.
Hi,
Thanks for your comment! The global template supports only User type of data reference. We cannot add the reference of contact, account, or any other entity. Which entity type you are using?
Hi All,
i used the steps and got the template id with list row and used expression in the outbound connector but still its giving me error
recipientType 8 != 112 template.templatetypecode and not GlobalTemplate
We are not able to replicate the issue.
So can you please provide the screenshot of action/step with error message in which you are facing issue.
Thanks!
recipientType 8 != 112 template.templatetypecode and not GlobalTemplate
i am getting this error even after using expression to get the template id
We tried to replicate the issue but it is working fine.
So, can you please provide the screenshot of the action/step with an error message where you are facing an issue?
Thanks!
I have read your article; it is very informative and helpful for me. I admire the valuable information you offer in your articles.
Hi everybody,
If people still happen to come through this article, because of the error “template.templatetypecode and not GlobalTemplate”, it might be because your template type and your recipient type needs to be the same.
In the example from this article, the email template is of type “contact”, therefore in recipients the input is “contacts(00000000-0000-0000-0000-000000000000)”
If you are using an email template of type case, your recipient would be “cases(00000000-0000-0000-0000-000000000000)”.
I hope this makes sense, this fixed the problem for me.