Thursday, November 17, 2022

PowerAutomate : How to send email from someone else using Sharepoint REST API

In this post I will explain how to send email as someone else and the reply to those email goes to this "someone".

Business Scenario which we had to use this:

We build an app for our Organization and we want the email to come from the APP instead of the person who has logged into the App. We wanted to use PowerAutomate to send emails instead of sending email from PowerApps. The reason was PowerAutomate gives you the history of every execution which helps for auditing and troubleshooting. We could achieve this using the Mail connector "Send an mail from a Shared mailbox (V2)". But inorder to use this one, everyone who uses the app need to have access to the shared mailbox to send email using that. This was very hard to achieve without someone keep granting the access manually to any new employees who join the organization.

The approach we took is 

1. Create a shared mailbox

2. Make a REST API Call to sharepoint online to send the email from sharepoint as if it is from this newly created shared mailbox. This is achieved using the connector "Send an htttp request to SharePoint"

This is how it looks in Power Automate



 Method : POST  
 Uri    : _api/SP.Utilities.Utility.SendEmail  
 Body   : {  
    'properties':  
    {  
      'From' : 'noreply_ajapp@xxxx.com.au',  
      'To': ["aj@xxxx.com.au"],  
      'CC': [''],  
      'Subject': ' Test Email ',  
      'Body': '<html>Hi,<br><br>  
            This is a TEST email. <br>  
            Thank you  
            </html>'  
    }  
 }   


There are few things which you need to be aware of before using this

1. It only works if the sender(the person using the app) has access to the Sharepoint site.

2. It cannot send emails to external users

3. It only works if the To and CC addresses are there in the user table of the sharpoint site. The users has to either access the sharepoint once or added to the sharepoint directly (not through a group) to the sharepoint site.

Check the below link to see how to add a user directly to the sharepoint

PowerAutomate: Grant access to a user to sharepoint using PowerAutomate


4. The to and cc can be a comma separate email addresses enclosed in single quote or double quote.

The email will look like this


The display name will be what is set for the shared mailbox. If you look closely, you can see the email address will be "no-reply@sharepointonline.com". But if you try to do a reply, it will go to the sharemailbox you have created.


Reference :

Power Apps and Power Automate: Send emails from anyone






Feel free to point out if anything is wrong/missing in this post.

No comments:

Post a Comment

PowerAutomate : How to send email from someone else using Sharepoint REST API

In this post I will explain how to send email as someone else and the reply to those email goes to this "someone". Business Scenar...