Do you need to send an email based on the membership of a SharePoint group in Power Automate?
Unfortunately, SharePoint groups don’t have an associated email address like the more modern Office group implementation.
This means you will need to get a list of your SharePoint group members and their emails. This can be done with an HTTP request to the SharePoint API.
This post will show you how to use the Send an HTTP request to SharePoint action to get the group members and then send them an email.
Get SharePoint Group Membership with HTTP Request
The first step in the process will be to use the Send an HTTP request to SharePoint action from the SharePoint connector to return an array of members.
This will return an array of members along with various data points that include the user’s email address.
Here’s how to get the group members.
- Add the Send an HTTP request to SharePoint action to your flow.
- Select the SharePoint Site Address that contains the group you want to email.
- Select GET as the Method.
_api/web/siteGroups/getByName('Your Group Name')/users
- Add the above path to the Uri field. Replace the
Your Group Name
with the name of your group. This can include space characters.
This API endpoint will return all the users in the group.
Select Email Addresses from HTTP Request Body
The HTTP action will return an array filled with a lot of data for each user.
To send an email to each user, you will only need their email address from the output. This means you will need to use a Select action to get an array that only contains the email address.
Here’s how to reduce the array to only contain the email field.
- Add the Select action from the Data Operations connector.
@{body('Send_an_HTTP_request_to_SharePoint')['d']['results']}
- Add the above expression to the From field. This is the array of group members returned from the Send an HTTP request to SharePoint action.
- Click on the Switch Map to text mode option to the right of the Map field input. This will switch the input into a single field.
@item()['Email']
- Add the above expression to the Map field. This will select only the Email field from each item in the array.
["john@example.com","ashley@example.com","tim@example.com"]
Now you will have an array that only contains email addresses. The output will look something like the above array.
Join Email Addresses
Now that you have an array with the email address, you will need to join these into a single delimited string that can be added to the To field in an email action.
This will create a comma or semicolon separated list of email addresses.
Here is how to convert the array to a delimited list of emails.
- Add the Join action from the Data Operations connector.
- Add the Output from the Select action to the From field of the Join action.
- Add a comma
,
or semicolon;
character to the Join with field.
john@example.com;ashley@example.com;tim@example.com
The result will look something like the above string.
Send an Email to Group Members
Now you will be able to use the output from the Join action to send your emails.
Here’s how to send an email with the joined string.
- Add the Send an email action from the Outlook connector.
- Click on the Switch to Advanced Mode option found to the right of the To field. You will need to first click into the To field before you will see the switch button. This will switch the field to a text input mode and allow you to use the out from the Join action.
- Add the Output dynamic content from the Join action in the To field.
- Add your Subject and Body to the email action as required.
Now the email will be sent to all the members of the SharePoint group. This is a dynamic solution since as the group membership changes it will change the output of the HTTP action.
Conclusions
SharePoint groups don’t come with an email address that can be used to email all members of the group.
Emailing the group members with Power Automate can still be achieved in a dynamic manner by using the HTTP action to list all members.
But, further manipulation is required to get only the email address.
Hope this has helped you to send emails to your groups in a flow. Let me know in the comments!
Hello. There are groups other than the person in the group I shot. However, the people in those groups do not come. How can I do it?
Sorry, not sure what you’re trying to ask.
When doing this method and sending myself an email with the output of the join operation in the body (to see what the output looks like), I am given
a list of emails as expected, however it does not include everyone who is listed as a member on the SharePoint site. There seems to be some kind of discrepancy between the modern SharePoint members list that can be found by clicking “Members” in the upper right corner of a SharePoint site, and the list inside People and Groups when looking at advanced permissions settings (Specifically by going to Site Permissions -> Advanced Permissions Settings, and clicking the Members group for the site).
So, the modern SharePoint members list successfully lists all members of the site, while the one inside settings does not, and since this method gets the group members from the place in settings I am unable to get a complete email list.
Any idea how to fix this? Thank you!
John, Thank you for your post. I was able to accomplish the above and I find that it works. I am running into one issue. The group I am sending an email to is larger than the outlook limit of 500 members. I have a group that ranges between 1875-1925 given how many people we add to the group verse how many we take out. Is there a medication for the above solution to break down the list of members it GETs and only email the first 500, sequentially the next 500, etc. until the list is completed?
Might be easier to create a Team for the group and message the Team?
Thanks for posting this, I was able to get this flow to work using a SharePoint Online user Permissions group, but ran into issues when I attempted the same outcome with an Office 365 Group … any thoughts? I am attempting to set up an Employee Resource Group with a Teams/SharePoint architecture and want to be able to leverage your post to easily communicate with the group-at-large via email when needed. Any help/education greatly appreciated!
Office 365 Group connector > List group members action should be used in this case.
I am building a workflow with parallel actions. Each branch has the same steps, but targets a different SharePoint group depending on a selection in the SharePoint list. This worked like a charm in the first branch, but in the second branch where I want to pull a different SharePoint group, I get the error “Correct to include a valid reference to ‘Send_an_HTTP_request_to_SharePoint’ for the input parameter(s) of action ‘Select_2’.” I’m stuck. Mahalo for any thoughts you may have.
You probably copied these actions. You need to update the references so they refer to the actions in the current branch and not the one you copied from.
It’s true, I did that the first time, but then I realized my error and started clean. I created each branch without copying and referred to the new action. (i.e., for the the first Select I used @{body(‘Send_an_HTTP_request_to_SharePoint’)[‘d’][‘results’]} and for the second, @{body(‘Send_an_HTTP_request_to_SharePoint 2’)[‘d’][‘results’]}. Thank you for your quick response! I’ll keep working at it today with a fresh brain. 😉
Send_an_HTTP_request_to_SharePoint 2
is missing an underscore. Should beSend_an_HTTP_request_to_SharePoint_2
SMH!! Thanks, John. That did the trick. Mahalo for the quick reply! If you ever come to Hawai`i, I owe you a Mai Tai.
The easiest way to send an email to a SharePoint group would be Sending an HTTP request with a SendMail Uri and just including the group title (with spaces and/or special characters) within the ‘To’ or ‘CC’ fields. Thus, the steps to retrieve the members of those groups will be eliminated. The only downside of this method is that you can’t use attachments with the HTTP calls, but you can include the links to the created files on SharePoint libraries.
There are 3 SharePoint groups included here: HR Officers, HR Assistants, Travel Section:
{
'properties':{
'To': ['HR Officers','HR Assistants'],
'CC': ['Travel Section'],
'Body':'Dear All,
The Request submitted for this Employee has been Fully Approved.
Regards,
SharePoint Applications',
'Subject':'Request for @{triggerOutputs()?['body/From/DisplayName']} is @{triggerOutputs()?['body/Status']}'
}
}
Nice, thanks for sharing! I might add this to the post at some point!
Would you also be able to share the HTTP request SendMail Uri?