Introduction
In this article we will learn about sending mail to SharePoint group members using power automate.
Let's start.
Step 1
Go to https://flow.microsoft.com/
Click on Automated--from blank

Step 2
Note
Here I use the trigger "When an item is Created" for automation, you can use as per your own needs.
Step 3
Select the site name and site address.
Step 4
Click on next, find and select the “Intialize variables” action.
Intialize 3 variables,
- Array
- Integer
- String

Step 5

Step 6
Click on next, find and select the “Send an Http request to sharepoint” action.

Step 7
- Site Address
- Method as "Get"
- in Uri coulmn fill as _api/web/sitegroups/getbyname('MYGroup')/users
- in Headers key :header,value:application/json; odata=verbose
Step 8
Click on next, find and select the “Parse Json” action.
Step 9
- Set content as "Body"
- in the schema click generate as sample,in the popup box paste the same shema for parse
Steps to get sample schema:
- open your sharepoint site in browser
- press F12 and choose developer console
- paste and enter the following code in the console
- function addScript(url) {
- var script = document.createElement('script');
- script.type = 'application/javascript';
- script.src = url;
- document.head.appendChild(script);
- }
- addScript('https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js');
- var="siturl";
- $.ajax({
- url: siturl+"/_api/web/sitegroups/getbyname('MYGroup')/users",
- method: 'GET',
- headers: {
- "Accept": "application/json; odata=verbose",
- "content-type": "application/json; odata=verbose",
- }, success: function (data){
- console.log(JSON.stringify(data))
- debugger;
- }});
Sample schema
- {"d":{"results":[{"__metadata":{"id":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(11)","uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(11)","type":"SP.User"},"Alerts":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(11)/Alerts"}},"Groups":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(11)/Groups"}},"Id":11,"IsHiddenInUI":false,"LoginName":"i:0#.f|membership|[email protected]","Title":"Grady Archie","PrincipalType":1,"Email":"[email protected]","Expiration":"","IsEmailAuthenticationGuestUser":false,"IsShareByEmailGuestUser":false,"IsSiteAdmin":false,"UserId":{"__metadata":{"type":"SP.UserIdInfo"},"NameId":"100320008986fac3","NameIdIssuer":"urn:federation:microsoftonline"},"UserPrincipalName":"[email protected]"},{"__metadata":{"id":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(13)","uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(13)","type":"SP.User"},"Alerts":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(13)/Alerts"}},"Groups":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(13)/Groups"}},"Id":13,"IsHiddenInUI":false,"LoginName":"i:0#.f|membership|[email protected]","Title":"Isaiah Langer","PrincipalType":1,"Email":"[email protected]","Expiration":"","IsEmailAuthenticationGuestUser":false,"IsShareByEmailGuestUser":false,"IsSiteAdmin":false,"UserId":{"__metadata":{"type":"SP.UserIdInfo"},"NameId":"1003200089837bf5","NameIdIssuer":"urn:federation:microsoftonline"},"UserPrincipalName":"[email protected]"},{"__metadata":{"id":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(6)","uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(6)","type":"SP.User"},"Alerts":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(6)/Alerts"}},"Groups":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(6)/Groups"}},"Id":6,"IsHiddenInUI":false,"LoginName":"i:0#.f|membership|[email protected]","Title":"Madhan Thurai NC","PrincipalType":1,"Email":"[email protected]","Expiration":"","IsEmailAuthenticationGuestUser":false,"IsShareByEmailGuestUser":false,"IsSiteAdmin":true,"UserId":{"__metadata":{"type":"SP.UserIdInfo"},"NameId":"10032000892ff6fa","NameIdIssuer":"urn:federation:microsoftonline"},"UserPrincipalName":"[email protected]"},{"__metadata":{"id":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(12)","uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(12)","type":"SP.User"},"Alerts":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(12)/Alerts"}},"Groups":{"__deferred":{"uri":"https://test.sharepoint.com/sites/check/_api/Web/GetUserById(12)/Groups"}},"Id":12,"IsHiddenInUI":false,"LoginName":"i:0#.f|membership|[email protected]","Title":"Miriam Graham","PrincipalType":1,"Email":"[email protected]","Expiration":"","IsEmailAuthenticationGuestUser":false,"IsShareByEmailGuestUser":false,"IsSiteAdmin":false,"UserId":{"__metadata":{"type":"SP.UserIdInfo"},"NameId":"100320008986fabd","NameIdIssuer":"urn:federation:microsoftonline"},"UserPrincipalName":"[email protected]"}]}}

Step 10
Click on next, find and select the “set variable" action.

Step 11
Name-choose users from dropdown
value-select results from dynamic box (alternatively you can use from expression box "body('Parse_JSON')?['d']?['results']")
Step 12
Click on Next Step and find and select the “Apply to Each” action.

Step 13
Inside apply for each action box, click add an action and find "Append to string varaible" and "Increament variable"

Expand the boxes and do the following

Where in append to string varaible value expression box enter "concat(variables('Users')[variables('i')]['Email'],';')" and click ok
Step 14
Click on Next Step and find and select the “Send an Email V2” action.

Step 15
Set the email address from the output of "Sharepoinggroup" and set the subject and email formatting as per your needs.

Step 16
Click on Save Flow.
Step 17
To
test the flow, insert a record in the list that you triggered. Then click the done button and
verify the email .
Step 18
Expected output

Conclusion
Hence we
learned about how to send emails to Sharepoint group members using power automate. I hope this helps someone, and happy
coding:)

Harry GrossmanPosted Apr 19, 2021, 6:47 PM
The code in step 9 is not working for me. It returns Undefined - using Chrome.
Sagar PardeshiPosted Apr 6, 2020, 11:43 AM
Madhan,,, Good Article and in this article learning part was a limitation of Power Automation we do not access directly SharePoint group name