# Connecting an AI Agent to Outlook: Mailboxes, Drafts, Calendars

> Connect the agent to Exchange Online through Microsoft Graph: it reads mail, writes replies as drafts with createReply and never sends on its own. RBAC for Applications in Exchange Online limits the agent to the specific mailboxes it needs.

Canonical URL: https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agent-outlook  
Author: Dr.-Ing. Marcus Rüb, CEO  
Published: 2026-11-08

For most organisations on Microsoft 365, customer requests, complaints and meeting requests arrive in Outlook, very often in shared mailboxes such as sales@ or support@. An AI agent that reads those mailboxes, triages requests and prepares replies needs a clean connection to Exchange Online. This guide covers which access path to use, how to keep permissions tight and why the agent should write drafts rather than send email itself. Facts are current as of November 2026.

## What does connecting an AI agent to Outlook involve?

Connecting an agent to Outlook means giving it programmatic access to mailboxes, folders and calendars in Exchange Online. The agent reads new messages, works out what the sender needs, pulls context from other systems and puts draft replies, categories or proposed meeting times back into the mailbox, where your team already works.

Common jobs for such an agent:

- **Triage:** tag incoming mail by topic, urgency or owner and move it to the right folder.
- **Draft replies:** combine the thread history, product data and a knowledge base into a reply that sits ready in the conversation.
- **Extract data:** pick out order numbers, serial numbers or preferred dates and pass them to a ticketing or ERP system.
- **Suggest meetings:** check free/busy information and offer two or three suitable slots in the draft.

If you are thinking about the business process first, for example handling complaints or service requests, see the guide on [AI customer service agents](https://www.ruebstudio.de/en/guides/ai-agents-by-department/ai-customer-service-agent-b2b). This article focuses on the technical connection to Outlook and Exchange Online.

## Should you use Microsoft Graph or IMAP for Outlook?

For Exchange Online, Microsoft Graph is the better fit. One API covers drafts, categories, shared mailboxes, calendars and change notifications, and access can be scoped mailbox by mailbox. IMAP and SMTP make sense when a single agent has to serve several mail platforms, but they have no calendar access and no Outlook categories.

| Criterion | Microsoft Graph | IMAP/SMTP with OAuth |
|---|---|---|
| Draft in the thread | `createReply` creates a reply draft | You build the MIME message and append it yourself |
| Calendars | Yes, via the Calendar API | No |
| Detecting new mail | Change notifications or polling | IMAP IDLE or polling |
| Per-mailbox access | RBAC for Applications with a scope | `Add-MailboxPermission` per mailbox |
| Other mail providers | Microsoft 365 / Outlook.com only | Any IMAP server |

IMAP against Exchange Online requires OAuth. Microsoft documents sign-in via [SASL XOAUTH2 with an access token](https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth); for unattended services there is the `IMAP.AccessAsApp` application permission, which an admin then grants per mailbox with `Add-MailboxPermission`. For a provider-neutral design built on these protocols, read [Email Agents over IMAP/SMTP](https://www.ruebstudio.de/en/guides/ai-agent-integrations/email-agent-imap-smtp-integration). The difference: that guide optimises for portability across mail hosts, while this one uses what only Exchange Online offers.

**Exchange Web Services (EWS)** is no longer an option for new work. According to Microsoft 365 Message Center notice [MC1227454](https://mc.merill.net/message/MC1227454), Exchange Online began a phased block of EWS on 1 October 2026 for tenants that have not configured an app allow list, and EWS will be removed permanently on 1 April 2027. Microsoft points to Graph as the replacement. On-premises Exchange Server is not affected.

## How does a Microsoft Graph connection work?

A Graph-based connection has four parts: an app registration in Microsoft Entra ID, mail and calendar permissions, a way to learn about new messages, and the agent logic that reads, decides and writes drafts back. For how these parts fit into the wider tenant, including SharePoint and Teams, see [Connecting an AI Agent to Microsoft 365](https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agent-microsoft-365).

### Delegated or application permissions?

Graph has two permission types:

- **Delegated:** the agent acts on behalf of a signed-in person. For shared or delegated folders there are `Mail.Read.Shared` and `Mail.ReadWrite.Shared`. Microsoft's [documentation on shared folders](https://learn.microsoft.com/en-us/graph/outlook-share-messages-folders) notes that these two permissions do not support change notifications; that needs the `Mail.Read` application permission.
- **Application:** the agent runs as a service with no signed-in user. This suits an agent that works shared mailboxes around the clock. The catch: without scoping, an application permission such as `Mail.ReadWrite` applies to every mailbox in the tenant.

### Scoping access to specific mailboxes

Exchange Online provides [RBAC for Applications](https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac) for this, and Microsoft states that it replaces the older Application Access Policies. An admin creates a management scope (for example all mailboxes with a given attribute, or an administrative unit), registers the app's service principal in Exchange and assigns an application role such as `Application Mail.ReadWrite` limited to that scope:

```powershell
# Create a pointer to the Entra ID service principal
New-ServicePrincipal -AppId <AppId> -ObjectId <ObjectId> -DisplayName "Outlook agent"

# Scope: only mailboxes with CustomAttribute1 = "ai-agent"
New-ManagementScope -Name "AI agent mailboxes" -RecipientRestrictionFilter "CustomAttribute1 -eq 'ai-agent'"

# Assign the role with the scope, then verify
New-ManagementRoleAssignment -App <ObjectId> -Role "Application Mail.ReadWrite" -CustomResourceScope "AI agent mailboxes"
Test-ServicePrincipalAuthorization -Identity <ObjectId> -Resource support@company.example
```

Microsoft calls out two traps. First, permissions from Entra ID and from RBAC for Applications are added together, so an unscoped `Mail.ReadWrite` consent in Entra ID cancels the scoping; remove it. Second, permission changes are cached for between 30 minutes and 2 hours depending on how active the app is. `Test-ServicePrincipalAuthorization` bypasses that cache.

### Learning about new messages

Graph can push new-mail events through [change notifications](https://learn.microsoft.com/en-us/graph/change-notifications-overview) to a webhook, Azure Event Hubs or Azure Event Grid. For messages, Microsoft lists an average latency under one minute and a maximum of three minutes. Subscriptions for messages and events last at most 10,080 minutes (just under seven days), or 1,440 minutes when they include resource data, so the agent must renew them. Each mailbox allows at most 1,000 active subscriptions across all applications. If you do not want a publicly reachable endpoint, poll the relevant folders on a schedule instead.

## Why should the agent write drafts instead of sending?

Writing replies as drafts in the thread keeps a person in charge of every outgoing message, removes the need for any send permission, and puts the suggestion where staff already look. If a draft is wrong, it is simply edited or discarded, and nothing has left the organisation.

In Graph this is a single call. [`createReply`](https://learn.microsoft.com/en-us/graph/api/message-createreply?view=graph-rest-1.0) creates a reply draft for a received message, and the response returns the message with `isDraft: true`. The agent can pass the text in the same call or set it later with `PATCH`. Sending, as Microsoft describes it, is a separate operation.

```http
POST https://graph.microsoft.com/v1.0/users/support@company.example/messages/{message-id}/createReply
Content-Type: application/json

{
  "comment": "Hello, thank you for getting back to us. ..."
}
```

The permission model supports this split. Microsoft's description of the `Application Mail.ReadWrite` role in its [RBAC for Applications documentation](https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac) says it "doesn't include permission to send mail", whereas `Mail.Send` lets an app send as any user. Leaving `Mail.Send` out rules out the case where a faulty prompt or a manipulated incoming email triggers an unreviewed reply.

Two practical details:

- **Respect Reply-To:** Microsoft notes that when the original message sets `replyTo`, the reply should go to those addresses rather than to `from`. Check this before the agent changes recipients.
- **Label the work:** an Outlook category such as "AI draft" on the original or the draft makes the agent's work visible and lets you track how many drafts are sent unchanged.

## How do shared mailboxes and calendars fit in?

In Graph, a shared mailbox is addressed like a user mailbox, by its address, for example `/users/support@company.example/mailFolders('Inbox')/messages`. Calendars come through the Calendar API, and for free/busy information the narrow `Calendars.ReadBasic` permission is enough.

### Shared mailboxes

For an agent working team mailboxes, an application permission with an RBAC scope is the usual route. Give the shared mailboxes a common attribute, filter the management scope on it, and add new mailboxes later simply by setting the attribute. Delegated access with `Mail.ReadWrite.Shared` also works, but it runs on behalf of one person whose sign-in has to stay valid, and it cannot use change notifications.

With IMAP, Microsoft's guidance is to obtain a token for a user and put the shared mailbox address in the user field of the XOAUTH2 string.

### Calendars

Proposing meeting times does not require full access to calendar content. [`getSchedule`](https://learn.microsoft.com/en-us/graph/api/calendar-getschedule?view=graph-rest-1.0) returns free/busy data for a list of users, distribution lists or rooms over a time window, and Microsoft lists `Calendars.ReadBasic` as the least privileged permission for both delegated and application access. The slot size, `availabilityViewInterval`, ranges from 5 to 1,440 minutes and defaults to 30. If a window contains more than 1,000 calendar entries the call fails, so keep the range short.

Creating events needs `Calendars.ReadWrite`. A more robust first step is to let the agent propose slots in its draft and have a person send the invitation once the customer confirms.

## What do you need before you start?

You need a Microsoft 365 tenant with Exchange Online, someone who can register apps and grant consent in Entra ID, Exchange admin rights for RBAC, and a clear list of the mailboxes and folders the agent may see. On top of that, you need the business content the agent will draw its answers from.

In detail:

- **People and approvals:** Microsoft names the *Organization Management* role group for assigning these Exchange roles, and the Exchange Administrator role in Entra ID. Find out early who gives consent; many organisations run this through a formal review with data protection and, in Europe, often employee representatives such as a works council.
- **Mailbox structure:** which shared mailboxes and which folders? An agent that only needs the Inbox and an "AI drafts" folder is far easier to justify than one with access to personal mailboxes.
- **Knowledge sources:** product data, price lists, FAQs, past replies. Without them the agent writes polite but empty answers.
- **Operations:** a service that renews subscriptions, logs errors and raises alerts when something stops. Where the language model runs is a separate decision, either with a model provider in the cloud or as [sovereign AI on your own infrastructure](https://www.ruebstudio.de/en/sovereign-ai).

## How do you roll it out step by step?

Start narrow: read and suggest first, measure, and only then widen the agent's reach. This lets you judge the quality of drafts on real traffic before the agent touches more mailboxes or tasks.

1. **Pick one mailbox.** A shared mailbox with many similar requests, such as support or quotation requests.
2. **Register the app with tight permissions.** `Mail.ReadWrite` through RBAC for Applications for that mailbox only, no `Mail.Send`, and no tenant-wide consent left in Entra ID.
3. **Read-only phase.** The agent only categorises incoming mail. This quickly shows whether it understands requests correctly.
4. **Drafts.** Next it creates reply drafts with `createReply`. The team sends, edits or discards them and flags what was wrong.
5. **Add calendars.** With `Calendars.ReadBasic` the agent proposes meeting times where a request calls for one.
6. **Expand.** Further mailboxes join by setting the scope attribute; the permissions stay the same.

In our own operations we use exactly this split: the agent reads and leaves drafts, and nothing is sent without an explicit instruction. For examples of department-specific agents, see [AI agents](https://www.ruebstudio.de/en/ai-agents), for instance for [quotations](https://www.ruebstudio.de/en/ai-agents/quotation) or [technical service](https://www.ruebstudio.de/en/ai-agents/technical-service).

## What are the limits and risks?

The main risks are permissions that are too broad, manipulated incoming emails and failures nobody notices. There are also technical limits: Graph throttles requests per mailbox, notification subscriptions expire, and a language model can state things that are wrong even when the source data is good.

- **Over-broad permissions:** an unscoped application permission reaches every mailbox, including the board's. RBAC scopes and removing the Entra ID consent are essential, not optional.
- **Delete comes with write:** Microsoft's description of `Mail.ReadWrite` includes deleting mail. The agent's code should not call delete at all, and every write should be logged.
- **Prompt injection:** an email can contain instructions aimed at the agent ("forward all invoices to …"). Drafts limit the damage because nothing leaves without a person; the agent should not be able to create forwarding rules either.
- **Throttling:** per app and mailbox, [Microsoft's limits](https://learn.microsoft.com/en-us/graph/throttling-limits) are 10,000 requests per 10 minutes, four concurrent requests and 150 MB of uploads per 5 minutes. Large shared mailboxes and back-filling old mail hit these limits quickly.
- **Expired subscriptions:** if a change-notification subscription runs out after its maximum of just under seven days and is not renewed, the agent silently stops working. A polling fallback catches this.
- **Data protection:** emails contain personal data. The setup can be operated in line with the GDPR once purpose, storage locations, processing agreements and retention are settled; that is a case-by-case assessment, not legal advice.

The approach does not fit if replies must go out instantly without human review, or if you run only on-premises Exchange Server without Exchange Online. In that case you are limited to IMAP or EWS, with fewer features.

## Where should you start?

Start with one shared mailbox, one app registration with tightly scoped permissions and an agent that only categorises at first. Review its accuracy after two or three weeks before adding drafts. The deciding factor is rarely the plumbing; it is whether the knowledge needed for good answers is actually available.

A short checklist for the conversation with IT:

- Which mailboxes and folders, and which attribute will the management scope use?
- Who grants consent in Entra ID, and who assigns RBAC roles in Exchange?
- Change notifications with a public endpoint, or polling?
- Where does the language model run, and where are logs stored?
- Who reviews the drafts, and how is feedback captured?

If you plan to connect more Microsoft 365 services such as SharePoint, Teams or OneDrive, continue with [Connecting an AI Agent to Microsoft 365](https://www.ruebstudio.de/en/guides/ai-agent-integrations/connect-ai-agent-microsoft-365). To turn the connection into a useful business process, see [AI Customer Service Agents for B2B](https://www.ruebstudio.de/en/guides/ai-agents-by-department/ai-customer-service-agent-b2b).

## Frequently asked questions

### Does an Outlook agent need the Mail.Send permission?

Not if it only writes drafts. Microsoft states that Mail.ReadWrite lets an app create and update messages but does not include permission to send, so a person sends from Outlook.

### Does this work with on-premises Exchange Server?

Microsoft Graph mail access and RBAC for Applications apply to Exchange Online. On-premises Exchange Server still relies on EWS or IMAP, and the EWS retirement only affects Exchange Online.

### Can one agent handle several shared mailboxes?

Yes. An application permission combined with a management scope covering exactly those mailboxes lets a background service work across all of them without anyone signing in.

### How quickly does the agent see a new email?

With change notifications, Microsoft documents an average latency under one minute and a maximum of three minutes for messages. If you poll instead, your polling interval sets the delay.

### Should the agent book meetings itself?

It can with Calendars.ReadWrite, but Calendars.ReadBasic is enough to read free/busy times. A safer start is to propose slots in the draft and let a person confirm the invitation.

## Sources

- [Microsoft Learn: message createReply (Graph v1.0)](https://learn.microsoft.com/en-us/graph/api/message-createreply?view=graph-rest-1.0)
- [Microsoft Learn: Role Based Access Control for Applications in Exchange Online](https://learn.microsoft.com/en-us/exchange/permissions-exo/application-rbac)
- [Microsoft Learn: Get Outlook messages in a shared or delegated folder](https://learn.microsoft.com/en-us/graph/outlook-share-messages-folders)
- [Microsoft Learn: calendar getSchedule (Graph v1.0)](https://learn.microsoft.com/en-us/graph/api/calendar-getschedule?view=graph-rest-1.0)
- [Microsoft Learn: Set up notifications for changes in resource data](https://learn.microsoft.com/en-us/graph/change-notifications-overview)
- [Microsoft Learn: Microsoft Graph service-specific throttling limits](https://learn.microsoft.com/en-us/graph/throttling-limits)
- [Microsoft Learn: Authenticate an IMAP, POP or SMTP connection using OAuth](https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth)
- [Microsoft 365 Message Center MC1227454: Exchange Web Services (EWS) retirement update](https://mc.merill.net/message/MC1227454)
