In this post let us learn how we can send email using email templates in Power Automate. Also, please note that this is very simple method of using SharePoint list as a templates list and then using some dynamic variables to replace the values before sending emails.
Lets take a default Issue Tracker list and try to send an email to the Assigned To person whenever an issue is created. The email should contain the following
- Email should sent to the Assigned To person
- Subject – A new issue has been created by Reported By Person
- Content – Should have the Issue Title, Priority and Reported Date
The output email should like the below
Let us also have a SharePoint list named Email Templates with the following fields.
- Title – Single line of text – Name of the email template
- Subject – Single line of text – Email subject with dynamic variable
- Content – Multiline rich text – Email body with dynamic variable
Based on our scenario, following is the email template that we are gonna use it for sending issue details to the respective assigned person.
Let’s start building Power Automate Flow
I have used a Manual Trigger, but you can create an auto trigger when an item is created or modified on the Issue Tracker list.
Get items – To get the email template
The first main action is to get the email template that we are gonna send when an issue is created. We have to use the Filter Query to filter the list which has an item with the title as New Issue. Since the list may have many email templates, its better to use the filter query to select the actual list template.
Condition – Check email template is available or not
This action is necessary to check whether the above action has returned any email template or not. If it is returned, then proceed with the actual logic, else terminate the flow. The following condition should be configured in this action to check the length of the body output from the above action.
Note: All the actions mentioned below should be under the Yes branch of the Condition action. There will be no actions under No branch unless you want to track the error.
Get Item – Get the actual issue
This action is used to get the actual issue and its metadata information that has to be passed to the email tempalte before sending it to the actual user.
Note: This action is not necessary when the trigger is set to auto when an issue is created or modified. Since I have used the manual trigger, I had to use this action to get the actual issue.
Next we are gonna use Compose action multiple times based on the list of dynamic variables that are to be replaced with the actual values. The method that we are gonna use is replace method with 3 params
replace('first param', 'second param', 'third param')
- First Param – Template value that needs to be replaced
- Second Param – dynamic variable name that needs to be replaced
- Third Param – The value that has to be replaced with dynamic variable
Following are the list of compose actions used based on our scenario
- To replace subject ~issuecreator~
- To replace ~displayname~ which is the assigned to user
- To replace ~issuetitle~ which is the issue title
- To replace ~issuepriority~ which is the issue priority
- To replace ~issuereporteddate~ which is the issue reported date
Lets start by adding the compose action
Compose – To replace the subject
For this action pass in the subject of the email template got above as a first param. ~issuecreator~ should be the second param and Issue Logged By value from the issue list must be the third param.
Compose – To replace assigned to
For this action pass in the content of the email template as the source followed by the dynamic variable ~displayname~ and Assigned To value from the issue list.
From the below action all the compose action should receive an output of the compose action defined above the appropriate compose action
Compose – To replace Issue Title
Compose – To replace Issue Priority
Compose – To replace Issue Reported Date
Send an email notification (V3) – Send the email with the dynamic values
The final action is send the email with all the updated values. Following are the params to the action
- To – Assigned to person email from the issue list
- Subject – Output of the compose which is used to replace the subject
- Body – The last compose action which is used to replace the dynamic variable
Conclusion & What’s next?
We have come to the end of the post, the flow that we learned above is very simple to send email values based on the template from the SharePoint list.
Please leave your comments and also let me know if you have any issues or any scenario that you want me to implement using Power Automate.
I hope you enjoy reading the post, see you soon in another post.
Cheers. Happy Flowing…