Search
Close this search box.
Logo der Arineo GmbH
18. February 2022
4 Minutes
Microsoft power platform Grafik Header

Set automatic Replies for Other Users Step by Step

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 Powerapps and PowerAutomate that allows you to simply select the Start/End date of your absence and your preferred substitute for that time.The App and Flows then will 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 Teams to your preferred substitute via PowerAutomate 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 PowerAutomate 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 PowerAutomate 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 today’s date.

Β 

Requirements

  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. PowerAutomate 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 user’s email address).

Β 

1. App-Registration

Login to the Azure Portal and go to Azure Active Directory > choose App Registrations
Click on the Plus-Symbol for new Registration
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 PowerAutomate 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 end date, 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:

Microsoft Power Platform Grafik
  • Note: be sure to set the Title Field to not required or add some text and set at least one entry of the start date 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:Β {πš‚πš‘πšŠπš›πšŽπš™πš˜πš’πš—πšπ™²πš˜πš•πšžπš–πš—π™½πšŠπš–πšŽπšπš˜πš›πš‚πšπšŠπš›πšπšπšŠπšπšŽ} 𝚎𝚚 ‘ {πšŽπš‘πš™πš›πšŽπšœπšœπš’πš˜πš— ‘πšƒπšŽπš‘πš π™΄πšπš’πšπš˜πš›

  • The Expression: Click into the filter query field. On the right hand, click expression. Type in “πšžπšπšŒπ™½πš˜πš (‘𝚒𝚒𝚒𝚒-𝙼𝙼-𝚍𝚍’)“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 πŸ™‚
  • Headers: Content-Type / application/json
  • Body: you can use this example:
    {
    “πšŠπšžπšπš˜πš–πšŠπšπš’πšŒπšπšŽπš™πš•πš’πšŽπšœπš‚πšŽπšπšπš’πš—πš”: {
    “𝚜𝚝𝚊𝚝𝚞𝚜”: “πš‚πšŒπš‘πšŽπšπšžπš•πšŽπš”,
    “πšœπšŒπš‘πšŽπšπšžπš•πšŽπšπš‚πšπšŠπš›πšπ™³πšŠπšπšŽπšƒπš’πš–πšŽ”: {
    “πšπšŠπšπšŽπšƒπš’πš–πšŽ”: “𝟸𝟢𝟷𝟿-𝟷𝟷-πŸΈπŸΈπšƒπŸ·πŸΎ:𝟢𝟢:𝟢𝟢.𝟢𝟢𝟢𝟢𝟢𝟢𝟢”,
    “πšπš’πš–πšŽπš‰πš˜πš—πšŽ”: “πš„πšƒπ™²”
    },
    “πšœπšŒπš‘πšŽπšπšžπš•πšŽπšπ™΄πš—πšπ™³πšŠπšπšŽπšƒπš’πš–πšŽ”: {
    “πšπšŠπšπšŽπšƒπš’πš–πšŽ”: “𝟸𝟢𝟷𝟿-𝟷𝟷-πŸΈπŸΎπšƒπŸ·πŸΎ:𝟢𝟢:𝟢𝟢.𝟢𝟢𝟢𝟢𝟢𝟢𝟢”,
    “πšπš’πš–πšŽπš‰πš˜πš—πšŽ”: “πš„πšƒπ™²”
    },
    “πš’πš—πšπšŽπš›πš—πšŠπš•πšπšŽπš™πš•πš’π™ΌπšŽπšœπšœπšŠπšπšŽ”: “<πš‘πšπš–πš•>\\\\\\\\\\\\\\\\πš—<πš‹πš˜πšπš’>\\\\\\\\\\\\\\\\πš—<πš™>𝙸’πš– 𝚘𝚞𝚝 𝚘𝚏 πš˜πšπšπš’πšŒπšŽ πšπš›πš˜πš–
    π™³πš’πš—πšŠπš–πš’πšŒ π™²πš˜πš—πšπšŽπš—πš πšπš˜πš› πš‚πšπšŠπš›πšπšπšŠπšπšŽ πšπš›πš˜πš– π™ΆπšŽπš π™ΈπšπšŽπš–πšœ π™°πšŒπšπš’πš˜πš— 𝚝𝚘 π™³πš’πš—πšŠπš–πš’πšŒ π™²πš˜πš—πšπšŽπš—πš πšπš˜πš› πš‚πšπšŠπš›πšπšπšŠπšπšŽ πšπš›πš˜πš– π™ΆπšŽπš π™ΈπšπšŽπš–πšœ π™°πšŒπšπš’πš˜πš—
    <πš‹πš›>\\\\\\\\\\\\\\\\πš—\\\\\\\\\\\\\\\\πš—\\\\\\\\\\\\\\\\πš—”,
    “πšŽπš‘πšπšŽπš›πš—πšŠπš•πšπšŽπš™πš•πš’π™ΌπšŽπšœπšœπšŠπšπšŽ”: “<πš‘πšπš–πš•>\\\\\\\\\\\\\\\\πš—<πš‹πš˜πšπš’>\\\\\\\\\\\\\\\\πš—<πš™>𝙸’πš– 𝚊𝚝 πšπš‘πšŽ π™²πš˜πš—πšπš˜πšœπš˜ πš πš˜πš›πš•πšπš πš’πšπšŽ πš›πšŽπšžπš—πš’πš˜πš— πšŠπš—πš πš πš’πš•πš• πš›πšŽπšœπš™πš˜πš—πš 𝚝𝚘 πš’πš˜πšžπš› πš–πšŽπšœπšœπšŠπšπšŽ 𝚊𝚜 πšœπš˜πš˜πš— 𝚊𝚜 𝙸 πš›πšŽπšπšžπš›πš—.<πš‹πš›>\\\\\\\\\\\\\\\\πš—\\\\\\\\\\\\\\\\πš—\\\\\\\\\\\\\\\\πš—”
    }
    }

6. Now we finally can use our OAuth Token from the app registration. Click on Show advanced options in the HTTP Action. To fill in the tenant Client ID and the secret, you must open the overview of the App-Refgistration in Azure Active Directory again.

Microsoft Power Platform Grafik
  • Authentication : Active Directory OAuth
  • Tenant: copy from App-Registration overview: Directory (tenant) ID
  • Audience: https://graph.microsoft.com
  • Client ID: Copy from App-Reistration overview: Application (client) ID
  • Credential Type: Secret
Power Platform Grafik
  • Secret: Navigate to Certificates and secrets and click on New client Secret. Copy & Paste.
Microsoft Power Platform Grafik

We are finished

Now you can test your Flow in the top right corner of the Flow editor and if a start date was set to today’s date and the email address of the requestor was correctly entered, it changes the automatic reply in Outlook to the text that we pasted in JSon Style.