Configuring Email Sending/Receiving with Microsoft Graph
This page describes the necessary steps to configure email sending and receiving using Microsoft Graph and an user with an Exchange Online maibox.
Pre-Requisites
Ensure you comply with the pre-requisites at Pre-Requisites (Virtual Networks) and Pre-Requisites (in that order) and that you have sufficient permissions to create new App Registrations in Microsoft Entra ID.
Ensure you comply with these additional pre-requisites:
Access to an account with Global Admin or Exchange Administrator permissions
Access to an available Exchange Online license
Have the ExchangeOnlineManagement PowerShell module installed in your machine or on Azure Cloud Shell
Creating mailbox and assigning Exchange Online license
If you have an existing mailbox you wish to use, you can skip this step. Otherwise, to create a new maibox:
In Azure Portal, navigate to Microsoft Entra ID
Click Add -> User -> Create New User in the top left corner

Create a new user with the desired email address (e.g.,
[email protected]).Go back to Microsoft Entra ID and open the Licenses -> Assignments menu
Verify if the user has an assigned license (for example, Microsoft 365 E3).
If not, assign a license that includes Exchange Online.
The mailbox will be automatically created after assigning a license.
Create App Registration
In the top-left corner of the Microsoft Entra ID page, click "Add -> App registration".
In the next page, choose a name for your app. We recommend a memorable and unique name so you can easily reference this registration in the future.
Choose which accounts can access your registration/app. We recommend setting "Accounts in this organizational directory only" (usually the default option), as this limits logins to users in your organization.
Your final registration will look something like this:

Hit "Register" once done.
Navigate to API Permissions -> Add a permission -> Microsoft Graph -> Application Permissions
Add the following permissions:
Mail.ReadWrite: SmartDocumentor requires this permission to read your mailbox, providing the functionality to upload files via EmailMail.Send: SmartDocumentor requires this permission to send emails from your mailbox, providing the functionality to send notifications and email confirmations
Check "Grant Admin Consent", which requires admin privileges. This is necessary as the permissions requested require privileged access to the mailbox.
In the registrations' page, head to "Certificates and Secrets" and click "New client secret". Name your secret and assign it a suitable expiration according to your compliance and security requirements.
Once created, copy the Value of the created secret to a secure temporary place. You won't be able to view this value after you leave this page.
Navigate to the "Overview" tab of the app registration, and copy the
Application (client) IDandTenant IDvalues.
Restricting mailbox access
This step is recommend otherwise SmartDocumentor will have unrestricted access to all mailboxes in your organization.
Open PowerShell and install the
ExchangeOnlineManamentmodule
Connect to Exchange Online with your admin email
Verify the mailbox you created before exists
If this command returns the details of the mailbox, it is correctly created.
Create the Application Access Policy to restrict your newly created App Registration to only use the mailbox you specified
Test the created policy:
If the result is AccessCheckResult : AccessAllowed then the configuration is correct - the app registration can only access the specified mailbox.
Optionally, you can manage access policies
Configuring email in application settings
With the app registration's values copied, navigate to the resource group where you deployed SmartDocumentor and find the Key Vault resource with the name
kv-app-config-xxxxxx, where the last 6 characters are unique to your deployment.Click the "Secrets" tab under "Objects" on the left.
Add the following six secrets with the following parameters:
Name: EmailWorkerConfiguration--Active , with value
true.Name: EmailWorkerConfiguration--ClientId , with the value set to the Client ID you copied in the previous step.
Name: EmailWorkerConfiguration--ClientSecret , with the value set to the Secret Value you copied in the previous step.
Name: EmailWorkerConfiguration--TenantId , with the value set to the Tenant ID Value you copied in the previous step.
Name: EmailWorkerConfiguration--FromEmail , with the email that will be set on the "From" field whenever SmartDocumentor sends an email with your configuration. Usually the same as your mailbox email configured previously.
Name: EmailWorkerConfiguration--UserId , with the same email as your configured mailbox.
Restarting the application
Navigate to the
smart-documentorContainer App and click the "Containers" tab under "Application". In this page, click "Save as a new revision" and wait until the revision is applied. If "Save as a new revision" is not available, simply disable and re-enable the container in the "Overview" tab.After restarting, the following changes will be in effect:
Confirmation emails are now sent to all accounts when registering in the platform
It is now possible to import files via email (Inbox -> Import -> Email for more information)
Various email notifications are now enabled (Expiring Secrets, Approval notifications, and more)
Summary
Creating mailbox and assigning Exchange Online license
Active and licensed mailbox
Create App Registration
App Registration configured
Restricting mailbox access
App registration can only access specified mailbox
Configuring email in application settings
Email configured in application settings Key Vault
Restarting the application
Email receiving and sending features enabled in the application
Additional Notes
Only one mailbox can be directly assigned to a restricted access policy.
To allow access to multiple mailboxes, create a group and use its ID as
PolicyScopeGroupId.Remember to renew the Client Secret before it expires (default 6–12 months).
Last updated