No module Published on Offcanvas position

Change user Out of Office application

I don't know if this is common with other companies, but it is where I work. People leave the company for various reasons, but sometimes they forget to set an Out of Office.
I don't keep track of this, but their teamlead/manager does and I get asked the question: "Can you check if Jane/Joe has his Out of Office set that he's no longer working here?" 

Lazy as I am and don't want to login into the Exchange ECP portal everytime, I developed my own tool so I can quickly check this and change the message and timeframe when needed. 

The code for this application can be found here:

The application is written in C# with and doesn't require a admin login to make the changes. It requires a App Registration in Azure AD to verify itself. 
To create one, do this:

  1. Login to your Azure Portal (
  2. Go to Azure Active Directory
  3. Go to App registrations
  4. Click on New Registration
  5. Give your new application a name
  6. For supported account types, if you require users to login to your application select Personal Microsoft Accounts only, for my use case I selected Accounts in this organizational directory only
  7. You can leave Redirect URI empty as this application doesn't talk back.

You have now created a App registration, but before the app can validate with Azure AD you will also need a Client ID and Secret, create one like this:

  1. On the page with your newly created App registration, go to Certificates & Secrets
  2. Click on the tab Client secrets
  3. Click New client sercret
  4. Give it a description so you easily recognize for what it is used for and a expiration date. 
  5. Take note of the Value field and Secret ID field

The app requires specific permissions to be able to read and write the users Out of Office settings. To set these settings do this:

  1. On the page with your newly created App registration, go to API permissions
  2. Click on Add a permission
  3. Click on Microsoft Graph
  4. Click on Application permissions
  5. Search for and add the following permissions
    • MailboxSettings.Read
    • MailboxSettings.ReadWrite
    • User.Read
    • User.Read.All
  6. Click on Grant admin concent for (Tentant Name)

This allows the app to read the settings for example the Out of Office for the user and to find the user based on the selection, the app also requires User.Read permissions.
Now you are all set to configure the application. Open the file in Visual Studio and all you need to do is configure the bearer token function


You'll find two parts here at Client_ID and Client_Secret where you need to fill the values of the App registration when you created a secret. 
Next you need to find your Tenant ID, otherwise the app will not know where to connect to. You can find the tenant ID in the overview of the Azure Active Directory Page
Once found, you can fill it in URL found in the var client line.


Once done, build your App and test if it works!