Sunday, 23 August 2020

Power Automate: Sending Emails without User Context

This article helps us to understand the way to send emails without the user context. This could be applicable for applications, where consumers/users are non-licensed.  

This could be achieved with the help of few set of actions on Power Automate flow. Here Microsoft graph end points are used to send emails on power automate, based on application permissions. The app permission needs to be enabled on Azure AD app. 

Let us only look at the power automate configuration, instead of end-end business scenario. The following snapshot shows the actions. 

Power Automate Flow : To send emails without user context

Configure & Enable App Permission on Azure AD App

Create an application on Azure AD, to enable the application permission for sending emails. The below snapshot shows the permissions configured and granted admin consent. 

Enable send mail permission on azure ad app

Enable tokens on the Azure AD application.

Enable tokens on azure AD app

From the azure AD app, extract the tenant ID, client ID and client secret. 

Extract Tenant ID, Client ID and Client Secret

Configure Power Automate Flow to Send Emails

The following set of actions are used in power automate. 

  • Trigger to start the power automate flow. 
  • Flow to call and get necessary token from Azure AD app –  
    • This is HTTP action, where Uri is auth token request endpoint, with necessary headers as shown. 
    • In the request body, client ID, client secret, grant type and resource details are configured as shown below. 
Action to get token from the above configured azure AD app

  • Receive and parse the token – Parse token action is used to parse the above response. The schema is generated with the help of body from above action. 
Parse the response to use the token

  • Send email action, where Microsoft graph send email end point is used, along with the above parsed token. The token is configured within authorization header. 
Send email HTTP action


The below snapshot shows the email triggered with the above flow.
Email Triggered from Above Flow