Power Automate Exchange

Please login or click SIGN UP FOR FREE to create your FlowUG account to join this user group.

Set automatic Replies for other users via MS Graph API - Step by step

By Philipp Schlund posted Jan 28, 2020 09:16 AM



Are you also tired of all the things you have to take care of when you are out of office for holidays, illness, etc?
We recently built a solution within Power Apps and Power Automate that allows you to simply select the start/enddate of your absence and your preferred substitute for that time and the App and Flows do all the necessary work for you while you can sit back and relax :) So far our solution manages the following:
  • Posting a clickable Message in MS Teams to your preferred substitute via Power Automate and sending back the response to the requestor.
  • Create a calendar-entry in Outlook
  • Create entries in Dynamics 365 for every day, leaving out weekend and fixed holidays
  • inform HR and additional Teams of your Choice via Message (Adaptive Card) in Teams
  • AND: Setting up the Automatic-Replies in Outlook for all Users in your Organization

(Note that only the last part is covered in this Post. If you are interested in the other ones, just leave a comment)

What we will do

  1. Show the App-Registration in Azure AD to be able to use the OAuth-Token with the MS Graph Api in Power Automate afterwards. 
  2. Set up the necessary Permissions for the MS-Graph Api to be able to change Automatic Replies for other Users than yourself.
  3. Create a Flow in Power Automate from scratch that runs on a daily basis and sets up the automatic Replies for a user when the startdate of an absence entry in a SharePoint list is equal to todays date.


  1. You need to be a global Admin to be able to do the App-Registration and set the mailbox Settings for other users or convince the global Admin to do the necessary steps for you. (Should be no problem, because this solution is as easy as it is awesome : )
  2. Power Automate License for HTTP-Request (Premium-Connector)
  3. Create a SharePoint list or use an existing one with at least a date column and a text column (for the users email adress).

1. App-Registration

  1. Login to the Azure Portal and go to Azure Active Directory > choose App Registrations
  2. Click on the Plus symbol for new Registration
  3. simply select a proper Name and select Accounts in this organizational directory only for the supported Account type. You can leave out the Platform configuration. That´s it, the overview shows the following:

2. Set up Permissions

  1. Navigate to API Permissions in the Menu. Click on Add a Permission. Choose Microsoft Graph and then Application permissions (as we don´t want to have a signed in user).
  2. search for MailboxSettings.ReadWrite, select it and click on Add Permissions. (You will receive an Info that the changes need Admin consent and that the changes are not yet granted for your tenant)
  3. In the API permissions Screen (same Screen) you can click Grant consent for your tenant. Now it might take up to 60 minutes for the changes to happen. Luckily we don´t have to sit around doing nothing as we still have to build our flow. (but you might as well get a cup of Coffee as we already finished most of the work already and in addition I would always recommend drinking Coffee.

3. Build the Flow in PowerAutomate

  1. Choose your Power Automate App in the O365 Portal or go to flow.microsoft.com
  2. Create a new Flow from Blank (skip all the settings or already type in a Name for your Flow)
  3. Search for Schedule as Connector and Choose Recurrence as a Trigger and pick your favourite Time.

  4. Add a new Action and add the Action Get Items ("Elemente abrufen") for the SharePoint Connector. For this purpose I built up a simple example list that contains the requestor ("Urlauber") start- and enddate which can be created/updated manually in our example (in our Solution this is done via Powerapps and PowerAutomate). The SharePoint List looks like this:

Note: be sure to set the Title Field to not required or add some text and set at least one entry of the Startdate to today´s date (we´ll need that to test the Flow later on.)

  • Site Address: Choose the Site Address where your List is Located. It Should be already listed. (if not, you can choose custom value and type in the URL.)
  • List Name: Pick your List Name from the dropdown
  • Filter Query: type in the query: {SharepointColumnNameforStartdate} eq ' {expression '
  • The Expression: Click into the Filter Query Field. On the right hand, Click Expression. Type in "utcNow('yyyy-MM-dd')"and click Update

 5. Add a HTTP Request Action. The Action should be automatically wrapped into an Apply to each Action without further Action

  • Method: Patch
  • URI: https://graph.microsoft.com/v1.0/users/dynamic Content/mailboxSettings. for the dynamic Content use the  SharePoint Column with the Mail adress of the Person who entered the holiday from the previous Get Items Action. (You should of course inform them before you test it, otherwise you might be in big trouble :) 
  • HeadersContent-Type    /   application/json
  • Body: you can use this example:

      "automaticRepliesSetting": {
        "status": "Scheduled",
        "scheduledStartDateTime": {
          "dateTime": "2019-11-22T18:00:00.0000000",
          "timeZone": "UTC"
        "scheduledEndDateTime": {
          "dateTime": "2019-11-28T18:00:00.0000000",
          "timeZone": "UTC"
        "internalReplyMessage": "<html>\n<body>\n<p>I'm out of office from 
    Dynamic Content for Startdate from Get Items Action to Dynamic Content for Startdate from Get Items Action 
        "externalReplyMessage": "<html>\n<body>\n<p>I'm at the Contoso worldwide reunion and will respond to your message as soon as I return.<br>\n</p></body>\n</html>\n"

6. Now we finally can use our OAuth Token from the App Registration. Click on Show advanced options in the HTTP Action. To Filkl in the Tenant, Cliendt ID and the Secret you      must open the overview of the App-Refgistration in Azure Active Directory again.

  • Authentication : Active Directory OAuth
  • Tenant: copy from App-Reistration Overview: Directory (tenant) ID
  • Audience: https://graph.microsoft.com
  • Client ID : Copy from App-Reistration Overview: Application (client) ID
  • Credential Type: Secret

  • Secret: Navigate to Certificates and secrets and click on New client Secret. Copy & Paste.

We are finished

Now you can Test your Flow in the top right corner of the Flow editor and if a Startdate was set to todays date and the Email Adress of the Requestor was correctly entered, it changes the automatic Reply for the  User in Outlook to the text and Start /Enddates (or any other dynamic content) that we pasted in JSon Style.