Send emails to SharePoint and Office 365 groups using Power Automate

In this article, we will create a Power Automate flow that will send emails to members of SharePoint and Office 365 Group.

We want to send activity alerts to the members of a team working on a project. We will use SharePoint Group and Office 365 Groups to send emails.

1. Create the flow for SharePoint Group

Let’s start creating the flow.

  • Go to https://make.powerautomate.com
  • Create an “Automated cloud flow”.
  • Write the “Flow name”.
  • Select the “When an item is created” trigger.
  • Click on the “Create” button.

You will be redirected to the following screen.

  • Select the “Site Address” from the 1st dropdown and the “List Name” from the 2nd drop-down.
  • Click on the “New step” button.
  • Add the “Send an HTTP request to SharePoint” action.
  • Select the “Site Address” and select the “Get” option from the “Method” dropdown.
  • Paste the following expression in the “Uri” field.
Expression:

_api/web/sitegroups(‘SharePoint_group_id’)/users

Note: Open your SharePoint group , see the group number from the URL, and replace SharePoint_group_id” with your group number.

To access SharePoint groups go to where ‘domain’ is your SharePoint site domain.

https://domain.sharepoint.com/_layouts/15/groups.aspx

Our group “PowerCloudTechnologies” contains the following users. All of them will get the mail when the flow runs.          

The “Send an HTTP request to SharePoint” action will be used to get details of the members of the SharePoint group.

  • Click on the “New step” button.
  • Add a “Select” action.
  • In the “From” field, go to “Expression” and paste the following expression.
Expression:

outputs(‘Send_an_HTTP_request_to_SharePoint’)?[‘body’]?[‘d’]?[‘results’]

This expression will get the output of the previous HTTP action.

  • Click on the “T” icon to enter a custom expression in the “Map” field.
  • Add the following expression in the “Map” field as shown below.
Expression:

item()?[‘Email’]

This expression will get the emails of all members of the group.

  • Click on the “New step” button.
  • Add a “Compose” action.
  • In the “Inputs” field, add the following expression.
Expression:

join(body(‘Select’),’;’)

This expression will separate member’s emails with a semicolon (;) .

  • Click on the “New step” button.
  • Add a “Send an email (V2)” action.
  • In the “To” field, add the “Outputs” of the “Compose” action.
  • Fill in the “Subject” and “Body” fields.

Now we will get the users of an Office 365 group.

2. Create the flow for O365 group

To access the groups, go to https://outlook.office.com/, click on the “Person” icon from the left navigation bar and click on the group’s dropdown, choose Owner and you will see the groups of which you are the owner, as shown below. Our group is “PowerCloud-Technologies”, and it has eight members.

  • In flow, click on the “New step” button.
  • Add a “List group members” action.
  • Select the group name from the “Group Id” dropdown.
  • Click on the “New step” button.
  • Add a “Send an Email (V2)” action.
  • In the “To” field, select “Mail” from dynamic content.
  • Fill in the “Subject” and the “Body” fields.

This “Send an email (V2)” action will automatically get wrapped in an “Apply to each” action because the group has multiple users.

Your flow is ready to work.

3. Testing

Create a new item in your selected list. All the members of your selected SharePoint and Office 365 group will receive the alert emails.

Mail received by SharePoint group members.

Mail received by Office 365 group members.

That’s IT Folks!