Send Email Dynamically Using PowerAutomate

Introduction

In this article, we will go through the steps of sending emails based on information stored in SharePoint list. This could be useful to sending email to users on following scenarios

  • when a particular task is finished
  • particular action got error.

The advantage here is there is no need to hard code the values in flow variables. All the information is dynamically gathered during the run time. Let's check the steps how to get this done.

Sending emails based on information stored in SharePoint list

Below are the steps needed to achieve to send email to dynamic users based out of information stored in SharePoint lists. At first we will configure SharePoint ‘Admins’ list according to below screen capture.

  • Title – default column of type ‘Single line of text’
  • DisplayName – to show the display name of the admin of type ‘Person or Group’
  • OptForNotification – is a ‘Yes/No’ check box field with default value configured to No. This column is used to enable or disable email notifications to be sent without touching flow design.

Step 1 - Go to URL https://flow.microsoft.com with your org account credentials and then select ‘New Flow’ and then select ‘Instant cloud flow’

Step 2 - Configure the flow name and trigger. Here I have chosen manually trigger a flow or simplicity ane named it is ‘SendEmailDynamically’.

 

Step 3 - Initialize variable ‘arrayEmail’ of type ‘Array’.

Step 4 - Get the items from the SharePoint list using ‘Get items’ action.

Please note that ‘Filter Query’ is defined to get the only items that have ‘OptForNotification’ option selected to ‘Yes’ in SharePoint list.

Step 5 - For each value got from ‘Get Items’ action select Email and then append to array variable. Please refer to below screen capture for reference.

Step 6 - Use the ‘join’ operation to separate the multiple email IDs with semi-colon. The variable arrayEmail is the output coming from ‘Append to array variable’.

Step 7 - Configure the email action according to below screen capture

Step 8 - Validate and test the output.

Conclusion

Thus in this article, we have seen how to send email dynamically by storing users information in SharePoint list. You can refer to the attached flow package to check the design.

References


Similar Articles