In this Power Automate tutorial, we will see how to send an email to a SharePoint group using Power Automate. And also we will discuss the below Points:
- Power automate send email to sharepoint group members
- Power automate send email to sharepoint group (Multiple SharePoint groups)
Power Automate send email to SharePoint group members
Here we will see how to send an email to SharePoint to the SharePoint group member.
So here I have created a SharePoint list called Events and I have a SharePoint called TsInfo group.
So when we create an event in the Event List, then an event notification send via email to each and every member present in that particular SharePoint group for example Developer group.
Steps to Send email to SharePoint group members using Microsoft Flow
Here we will see how to send an email to SharePoint group members using Microsoft Flow.
Step 1: Create a SharePoint Event list
I have already created an Event list with 2 columns with column type listed below.
Column | Column Type |
---|---|
Title | Single Line of text |
Event Date | Date and Time |
Once your SharePoint list is created we will move towards Power Automate to create a flow.
Step 2: Create a Flow in Power Automate
To create a Flow, log in to Power Automate, then click on Create icon and select Automated cloud Flow.
Now Provide the Flow name, and select the trigger as When an item is created -SharePoint list, to start the Flow. Then click on Create.
Step 3: When an item is created in SharePoint List
In this step provide the site address and List name in which you will create an event.
Step 4: Get SharePoint group user-id
To get the Sharepoint group user id, we need to call SharePoint and it will return the group members by using the ‘send HTTP requests to SharePoint’ action.
So we need to pass the site address which contains the group. And the Method of call is ‘Get’ because we want to call Rest API and have it get information for us. Then we will provide the ‘URI’, which is the endpoint of the SharePoint Rest API.
So, click on the Next step, and select the ‘Send an HTTP request to SharePoint‘ action. Then provide the site address and select the ‘Get’ as Method.
Then in Uri, write the RestApi, and here 5 is my Group id, which you can get from your SharePoint group URL like the below image.
_api/web/sitegroups(5)/users
Step 5: Fetch the Emails of Group members from JSON
To Fetch the email we will take the help of JSON code which we get in the previous step by using Select action.
So click on the Next step, and then select the Select action. Then in From field write the below expression:
In the expression d and results are the two-node where the array is present, you can get these two node from the SharePoint http request result/output.
body('Send_an_HTTP_request_to_SharePoint')?['d']?['results']
Then in the Map field change it into the Text mode, and then write the below expression.
item()?['Email']
Step 6: Get email semicolon-separated from the Email array
To send an email we need to convert the array of emails to string with semicolon-separated.
So click on the Next step and then select Compose action. In the input Field write the below expression:
join(body('Select'),';')
Step 7: Send an Email to Group members
To send an email to the group members, click on the Next step and select the ‘Send an Email(V2)‘ action.
Then in the To field set the output of compose action, and then Provide the title and body of the Email.
Once your Flow is ready you can run the flow manually.
Step 8: Run the Flow
To run the Flow create an item in the Event list like the below screenshot
So in TSInfo group have two members you can see in the below screenshot.
Once your Flow ran successfully, you will get an email in Outlook.
This is how Power automate send email to SharePoint group members
Read Power Automate remove characters from a string
Power automate send email to Sharepoint group (Multiple SharePoint groups)
Here we will see how to send an email to the multiple SharePoint groups using Power Automate.
We will use the above SharePoint list i.e. Event list, so here when an event is created then we will send an email to each user from all the groups present on the SharePoint site.
For example, there are two groups like Testing group and the Developer group. In the Testing group, there are 2 members such as user 1 and user 2 and in the Developer group, there are 2 members such as user 2 and user 3.
So, an email will send to user 1, user 2, and user 3 members of all the groups present on the SharePoint site.
Steps to send an Email to SharePoint group using Microsoft Flow
Here we will see how to send an Email to the SharePoint group using Microsoft Flow.
We will use the Event list in SharePoint which we have already created in the above topic. And here we will send email to multiple groups so, I have two groups in the SharePoint site and their members, in the below screenshot.
- TSInfo group members
2. SharePoint Developer group members
Once you have a SharePoint group and SharePoint list follow the below steps to send an email to SharePoint group using Microsoft Flow.
Step 1: Create a Flow in Power Automate
To create a Flow Login to Power automate and click on Create icon then select Automated cloud flow.
Now Provide the Flow name and select the trigger When an item is created to run the Flow and then click on Create.
Step 2: When an item is created
In this step, provide the site address and list name where the list is present on SharePoint.
Step 2: Declare an array variable with Group id
To store group id, we will initialize an array variable, so click on the Next step and then select Initialize variable action. Then set the variable name, type as an array, and then in value add the group id of your group.
You can get your group id from the URL of the SharePoint group.
Once you collect the group id of all the groups you want to send an email, then add to the value like below
Step 3: Initialize 3 variables
In this step, we will initialize three variables, so click on the Next step and select initialize variable action. Then set the variable name and type like below
Step 4: Process the Group id
To process the Group ids, we will use apply to each so, click on the Next step and then select Apply to each action.
Then set the value by selecting the Group id variable from dynamic content.
Step 5: Get the current Group id
To get the current group id, inside Apply to each action, click on Add an action and then select Set variable action. Then in Name select Current Group id variable and then in value select current item from the dynamic content.
Step 6: Get the SharePoint Group Members
To get the SharePoint group members, we will send an HTTP request to SharePoint and it will return the members of each group.
In this action, we will send the Url of the SharePoint site which contains the group. And the method for this call is the Get method because we want to call the Rest API and have the information for us. And the URI field is the endpoint of the SharePoint rest API.
So, click on the Next step and then select the Send HTTP request to SharePoint action. Next, provide the site address, choose the Method as Get and then in Uri write the below rest API. Inside site groups method assign the group id.
_api/web/sitegroups()/users?$select=Email
And add the headers and values like below screenshot
Step 7: Parsing the Result
Now we have a JSON code from the output/result from the previous step, we need to loop through the results, called parsing, to get the result we can use in the flow.
So for this click on Next step and select Parse JSON action. In the content, we will add the body of the HTTP request, and in the schema, and the result of the previous step to ‘Generate From sample’,. You will get the sample of parse JSON like below:
{
"type": "object",
"properties": {
"value": {
"type": "array",
"items": {
"type": "object",
"properties": {
"Email": {
"type": "string"
}
},
"required": [
"Email"
]
}
}
}
}
Step 8: Apply to each user Email
In this step, we will apply to each user email to get the unique email that we get from the previous step.
So Inside the Apply to each action, click on Add an action and select the Apply to each action, then in value select the value of the parse JSON from the dynamic content.
Step 9: Get the current Email
In the next step, we will collect the current email, so click on Add an action in apply to each 2, select Set variable action, and in Name field select CurrentEmail variable. Then in the value set the Email of parse JSON from the dynamic content.
Step 10: Remove duplicate Email
In this step, we will remove the duplicate email by using Contains(), and then we will append the email to the string variable.
For this click on Add an action inside Apply to each action(2), select Condition control action. And in value, we will add an expression i.e. the current email contains the user email. If the current email does not contain the user email then an email will append to the string variable.
So, write the below expression in value then is not equal to and set the true.
contains(variables('EmailRecipents'), variables('CurrentEmail'))
If the condition is true, then select the Append to string variable action. In Name select the EmailRecipent and in value add the Email from the Parse JSON from dynamic content.
Step 11: Send an email to members of each group
In this step, we will send an email that is collected in the string variable, so click on the Next step and select Send an Email(V2) action.
In the To field, set the EmailRecipents variable from the dynamic content, and then add the Subject and body field.
Once your flow is ready, we can run the flow manually
Step 12: Run the Flow
Now click on save and run the flow manually, to run the flow create an item in the event list.
Once your Flow ran successfully, users of each Sharepoint group will get an email like below.
This is how Power automate send email to all SharePoint group works.
Related Power Automate tutorials:
- Microsoft Flow Examples: Send a customized email when a new SharePoint list item is added
- Microsoft Flow Send approval email when a new item is added in SharePoint Online Office 365
- Microsoft Flow: Save my email attachments to a SharePoint document library
- Send a reply when a new email arrives on Gmail using Power Automate
- On-premises Data Gateway Installation and Configuration for Microsoft Flow
- Send a Happy Birthday email to employees using Microsoft Flow in SharePoint Online
- Power Automate Desktop Flow
In this Power Automate tutorial, we learned how to send an email to SharePoint groups using Microsoft Flow. And also we discuss the below Points:
- Power automate send email to sharepoint group members
- Power automate send email to sharepoint group (Multiple SharePoint groups)
Bhawana Rathore is a Microsoft MVP (3 times in Office Apps & Services) and a passionate SharePoint Consultant, having around 10 years of IT experience in the industry, as well as in .Net technologies. She likes to share her technical expertise in EnjoySharePoint.com and SPGuides.com
Is there a size limit to the group members such that the flow will no longer send emails?
This is very helpful, thank you for posting this. I re-created the multiple SharePoint groups flow and after running it, the follow error occurs:
InvalidTemplate. Unable to process template language expressions for action ‘Apply_to_each_2’ at line ‘0’ and column ‘0’: ‘The template language expression ‘body(‘Parse_JSON’)?[‘value’]’ cannot be evaluated because property ‘value’ cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.’.
I’m not sure what I did wrong since I virtually followed the above flow to the tee (except changing to local source where appropriate). I’m relatively new to Power Automate, so any help is appreciated!
sorry, it didn’t work for multiple user group.
“Steps to send an Email to SharePoint group using Microsoft Flow” is incomplete as the section is missing several steps. You don’t explain how you go from step 4 to step 5.
I have try above steps showing error how to resolve it.
{“[email protected]”:””};
{“[email protected]”:””};