Thank you for visiting my site!

Home / Power Automate - Flows / Send Mail To SharePoint Group Members on Item created – Loop an Array.

Send Mail To SharePoint Group Members on Item created – Loop an Array.

based On:

https://www.c-sharpcorner.com/article/send-mail-to-sharepoint-group-members-using-power-automate/

https://www.sharepointsiren.com/2018/12/flow-send-email-to-sharepoint-group-members/

This is the flow steps:

Step 1.
Create a flow Automated-from blank in the popup select “When an item is Created”.

Step 2.

Initialize 3 variables
  1. Array
  2. Integer
  3. String

Step 3

Send an Http request to SharePoint

get the Users from a User group:
_api/web/sitegroups/getbyname(‘User Group Name’)/users

Headers key :header

value: application/json; odata=verbose

Step 4.

Parse the request.

Paste the code below to  Generate from file.

{ "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "d": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "results": { "type": "object", "properties": { "type": { "type": "string" }, "items": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "__metadata": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "id": { "type": "object", "properties": { "type": { "type": "string" } } }, "uri": { "type": "object", "properties": { "type": { "type": "string" } } }, "type": { "type": "object", "properties": { "type": { "type": "string" } } } } } } }, "Alerts": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "__deferred": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "uri": { "type": "object", "properties": { "type": { "type": "string" } } } } } } } } } } }, "Groups": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "__deferred": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "uri": { "type": "object", "properties": { "type": { "type": "string" } } } } } } } } } } }, "Id": { "type": "object", "properties": { "type": { "type": "string" } } }, "IsHiddenInUI": { "type": "object", "properties": { "type": { "type": "string" } } }, "LoginName": { "type": "object", "properties": { "type": { "type": "string" } } }, "Title": { "type": "object", "properties": { "type": { "type": "string" } } }, "PrincipalType": { "type": "object", "properties": { "type": { "type": "string" } } }, "Email": { "type": "object", "properties": { "type": { "type": "string" } } }, "IsEmailAuthenticationGuestUser": { "type": "object", "properties": { "type": { "type": "string" } } }, "IsShareByEmailGuestUser": { "type": "object", "properties": { "type": { "type": "string" } } }, "IsSiteAdmin": { "type": "object", "properties": { "type": { "type": "string" } } }, "UserId": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "__metadata": { "type": "object", "properties": { "type": { "type": "string" }, "properties": { "type": "object", "properties": { "type": { "type": "object", "properties": { "type": { "type": "string" } } } } } } }, "NameId": { "type": "object", "properties": { "type": { "type": "string" } } }, "NameIdIssuer": { "type": "object", "properties": { "type": { "type": "string" } } } } } } } } }, "required": { "type": "array", "items": { "type": "string" } } } } } } } } } } } } }}

Step 4.

Set variable Users with the results from Parse JSON

set the value to: body(‘Parse_JSON’)?[‘d’]?[‘results’]

Step 5.

Add  loop,

set the Group to: concat(variables(‘Users’)[variables(‘i’)][‘Email’],’;’)

i = 1,

Step 6

Send email to Group

 

ADD YOUR COMMENT