Skip to content
Skip to content

Practical automation guide · By Yes AI

Limit an automation to one Microsoft 365 mailbox

Published 6 min read

Many automations start by reading a shared mailbox, such as accounts or orders. In Microsoft 365, the usual application permission for that reads every mailbox in the organisation. This guide shows how an administrator can limit access to the mailboxes a workflow needs, and how to test that the limit works.

Quick answer

The Microsoft Graph application permission Mail.Read, granted in Microsoft Entra ID, lets an app read mail in all mailboxes. To limit an automation to one mailbox, an Exchange administrator assigns the permission through RBAC for Applications in Exchange Online with a management scope or administrative unit, removes the tenant-wide grant from Entra ID, and checks the result with Test-ServicePrincipalAuthorization.

IT administrator in a Newcastle office configuring settings on a laptop with a blurred admin console

Why does the usual permission read every mailbox?

Automations run without anyone signed in, so they use application permissions. Microsoft's Graph permissions reference describes the application version of Mail.Read as allowing the app to read mail in all mailboxes without a signed-in user. The delegated version reads only the signed-in user's mailbox, but that ties the automation to one person's account and sign-in. Granting the application permission in Entra ID with no further limit means a leaked client secret or certificate exposes every mailbox in the organisation, including the directors' and payroll's, when the workflow only needed the accounts inbox.

What is RBAC for Applications in Exchange Online?

RBAC for Applications lets an Exchange administrator grant an app permission to Exchange Online data and pair it with a resource scope that sets which mailboxes the app can reach. Microsoft states that it replaces Application Access Policies and works for Microsoft Graph and Exchange Web Services. The scope can be a management scope, which selects mailboxes with a filter on their properties, or a Microsoft Entra administrative unit. The person making the assignment needs to be in the Organization Management role group, or hold the Exchange Administrator role in Entra ID.

How is a scoped permission set up?

The work is done in Microsoft Entra ID and Exchange Online PowerShell. It suits a provider working under your administrator's supervision, with each change recorded. A management scope selects mailboxes with a filter on their properties, so a common approach is to set a custom attribute on the shared mailbox and filter on that attribute. Microsoft's documentation includes worked examples of both a management scope and an administrative unit. The outline below follows that documentation; use the current version of the page for exact parameters.

  • Register the app in Microsoft Entra ID without granting tenant-wide Mail.Read.
  • In Exchange Online, create a pointer to the app's service principal with New-ServicePrincipal.
  • Create a management scope whose filter matches only the target mailbox, or use an administrative unit.
  • Assign the role, for example Application Mail.Read, with New-ManagementRoleAssignment and the scope.
  • Check the result with Test-ServicePrincipalAuthorization against an in-scope and an out-of-scope mailbox.

Why must the tenant-wide grant be removed?

Microsoft's documentation states that permissions from Entra ID and from Exchange RBAC for Applications are combined. If the app holds Mail.Read in Entra ID and a scoped Mail.Read in Exchange, the result has no effective scoping, because the Entra grant already covers every mailbox. Remove the Entra ID grant once the scoped assignment is in place and tested. Microsoft also notes that exclusive management scopes do not restrict app access, so use a normal management scope or an administrative unit. Keep a record of which grants exist in each place, so a later change does not quietly add tenant-wide access back.

How do you test that the limit works?

Run Test-ServicePrincipalAuthorization for the app against a mailbox that should be in scope and one that should not. The result shows InScope as true or false for each permission. This test bypasses Microsoft's permission cache, but live API calls do not: Microsoft says permission changes take between 30 minutes and 2 hours to apply, depending on how recently the app was used. After that period, make a real Graph call to an out-of-scope mailbox and confirm it is refused. Record both tests with the date, so the next review can repeat them.

What about sending mail, and Google Workspace?

Sending is a separate permission. The application Mail.Send permission allows an app to send mail as any user, so scope it the same way if the workflow sends replies. Choose the smallest role that does the job: Mail.ReadBasic, for example, excludes message bodies and attachments, which suits a workflow that only routes emails by sender and subject. In Google Workspace, domain-wide delegation lets a service account access users' data without their consent. Google advises checking that the app or service account has an appropriately small scope of access, so grant only the API scopes the workflow needs.

How should the app's credentials be looked after?

A scoped permission limits the damage if a credential leaks, but the credential still needs care. Prefer a certificate over a client secret where the automation platform supports it, and store either in a secrets vault, not in a workflow's settings screen or a shared document. Give it an expiry date and put the renewal in someone's calendar, because an expired secret stops the workflow without warning. Review the app's sign-in logs in Entra ID from time to time for unexpected locations or failures. When the provider changes or the workflow is retired, remove the role assignment, the service principal pointer and the app registration.

Mailbox access options for an automation

ApproachWhat the app can reachAdmin effortWhen it fits
Application Mail.Read granted in Entra IDEvery mailbox in the organisationLowRarely appropriate for a single workflow
RBAC for Applications with a management scopeMailboxes matching the scope filterModerate; needs Exchange Online PowerShellUnattended workflows on shared mailboxes
RBAC for Applications with an administrative unitMailboxes in the administrative unitModerateSeveral mailboxes managed as a group
Delegated permission with a signed-in userThe signed-in user's mailboxLow, but tied to one person's sign-inTools a person runs while signed in
Forwarding rule to an intake addressOnly the forwarded messagesLowSimple intake where replies are sent elsewhere

Practical checklist

  • The automation's app has no tenant-wide Mail.Read or Mail.Send grant in Entra ID.
  • A management scope or administrative unit covers only the mailboxes in scope.
  • Test-ServicePrincipalAuthorization shows true for target mailboxes and false for others tested.
  • A live call to an out-of-scope mailbox is refused after the permission cache period.
  • The client secret or certificate is stored securely, with an expiry date someone owns.
  • Each administrator change is recorded with who approved it.

Common questions

We set up Application Access Policies before. Do they still work?

Microsoft states that RBAC for Applications replaces Application Access Policies, and its documentation notes that permissions granted in Entra ID can only be constrained with Application Access Policies. If you rely on an existing policy, keep it until a scoped RBAC assignment is in place, the Entra grant is removed and testing confirms the new limit. Check Microsoft's current guidance before changing either.

Can a small business without an IT department do this?

It needs an account with Exchange administrator rights and some PowerShell. Many small businesses have an IT provider or the automation provider make the changes while the business owner watches and keeps a record. The important part for the business is approving which mailboxes are in scope and keeping the test results.

Does Mail.Read include attachments?

Yes. The application Mail.Read permission covers message contents, including attachments. Mail.ReadBasic excludes the body, preview, attachments and extended properties. An invoice intake workflow needs attachments, so it needs Mail.Read on the accounts mailbox only. A workflow that sorts mail by sender and subject may need only Mail.ReadBasic.

How long does a permission change take to apply?

Microsoft states that changes to app permissions are subject to a cache that lasts between 30 minutes and 2 hours, depending on the app's recent activity. Test-ServicePrincipalAuthorization bypasses that cache, so it shows the intended result straight away. Allow for the cache period before confirming with a live call.

Does this affect other apps or users?

The role assignment applies to the service principal you assign it to, so other apps and users keep their existing access. Removing a tenant-wide grant from one app does not change anyone's own mailbox access. Check that no other workflow was sharing the same app registration before you remove its grant.

Sources and further reading

Continue planning

Turn the guide into your workflow

Bring one process, the systems it touches and the exceptions your staff handle. We can discuss approval boundaries, recovery steps and the evidence needed before changing live operations.