Send Email To SharePoint Groups From MS Flow

In this article, you will learn how to send email to SharePoint Groups from MS Flow.

If you are working on SharePoint, you know it is easy to send an email to SharePoint groups through SPD/Nintex workflows, because these are the apps related to SharePoint which know the SharePoint context. On the other hand, MS Flow is a separate Office 365 app and independent of SharePoint but this also helps in automating the workflows. However, here comes the issue. MS Flow can recognize the O365 users but there is no straightforward way to get the SharePoint group users from the dynamic data.
 
There are different ways to achieve this solution. In one of the articles I read online, the user did a REST call to get all the group users from the group and had to use foreach loop to get all the users' email ids in a variable. Then, he used that variable to send an email. But I found the following way very simple and time saving.
 
In short, we are going to send an email via SharePoint Rest API by hitting "/_api/SP.Utilities.Utility.SendEmail"  pointing to send the email to SharePoint group.
 

Steps

  1. In your flow, add this step – Send an HTTP request to SharePoint.

    Send email to SharePoint groups from MS Flow

  2. Fill in the following details.

    1. In the Site Address, select your SharePoint site URL.
    2. Select the method as POST.
    3. In URI, add this endpoint : /_api/SP.Utilities.Utility.SendEmail
    4. In headers, accept application/json;odata=verbose
      content-type: application/json;odata=verbose
    5. In Body, write the following code.
      1.       {  
      2.         'properties': {  
      3.             '__metadata': {  
      4.                 'type''SP.Utilities.EmailProperties'  
      5.             },  
      6.   
      7.             'To': {  
      8.                 'results': ['test group ']  
      9.             },  
      10.             'Body''<p>This is a test email</p>',  
      11.             'Subject''Test email from MS Flow'  
      12.         }  
  1. Please check the screenshot to verify.

    Send email to SharePoint groups from MS Flow

  2. Now, run your workflow. I created a test group in which two users were present. Below is the email that I have received from no-reply@sharepointonline.com. This is another advantage using SP utilities to send email. If you use default send email action, the MS Flow runs on the context of the user who created the flow and sends email from his email id. So, going with SP utilities is a great advantage if you wanted to send system-generated type of emails.

    Send email to SharePoint groups from MS Flow