Microsoft Outlook Mail
Microsoft Outlook Mail is a professional email service that's part of Microsoft 365. This connector enables AI assistants to read, send, search, and manage emails, attachments, mail folders, and mailbox settings through the Microsoft Graph API.
Authentication Types
Microsoft Outlook Mail supports OAuth 2.0 authentication via the Microsoft identity platform:
- OAuth - Standard OAuth 2.0 authorization flow with PKCE
- Pros: Secure delegated access, per-user mailbox access, automatic token refresh
- Cons: Requires Azure app registration, user consent needed
- Best for: Production applications, user-specific email operations
Setting up OAuth
1. Register an Application in Azure Portal
-
Go to Azure Portal
-
Navigate to Microsoft Entra ID (formerly Azure Active Directory)
-
In the left sidebar, click App registrations
-
Click New registration
-
Fill in the application details:
- Name: Choose a descriptive name (e.g., "Webrix Outlook Mail Integration")
- Supported account types: Select the appropriate option:
- "Accounts in this organizational directory only" for single-tenant apps
- "Accounts in any organizational directory" for multi-tenant apps
- "Accounts in any organizational directory and personal Microsoft accounts" for the widest support
- Redirect URI: Select "Web" and enter:
- For SaaS deployments:
https://{org}.mcp-s.com/{org}/api/auth/callback - For On-Premise deployments:
{connectUrl}/{org}/api/auth/callback
- For SaaS deployments:
-
Click Register
2. Configure API Permissions
-
In your app registration, click API permissions in the left sidebar
-
Click Add a permission
-
Select Microsoft Graph
-
Choose Delegated permissions
-
Add the following permissions based on your needs:
Essential permissions:
User.Read- Sign in and read user profileMail.Read- Read user mailoffline_access- Maintain access to data (enables refresh tokens)
For sending emails:
Mail.Send- Send mail as a user
For managing emails (move, delete, drafts, folders):
Mail.ReadWrite- Read and write access to user mail
For mailbox settings (automatic replies, etc.):
MailboxSettings.Read- Read user mailbox settingsMailboxSettings.ReadWrite- Read and write user mailbox settings
-
Click Add permissions
-
Important: Click Grant admin consent for [Your Organization] if you have admin rights.
Some permissions require admin consent. If you see "Admin consent required" next to a permission, ask your tenant administrator to grant consent.
3. Create Client Secret
-
In your app registration, click Certificates & secrets in the left sidebar
-
Under Client secrets, click New client secret
-
Add a description (e.g., "Outlook Mail Connector Secret")
-
Choose an expiration period (recommended: 12 months or 24 months)
-
Click Add
-
Important: Copy the secret Value immediately - it will only be shown once!
Store the client secret securely. If you lose it, you'll need to create a new one.
4. Get Your Credentials
You'll need these values to configure the connector:
- Application (client) ID: Found on the app registration Overview page
- Client Secret: The value you copied in the previous step
5. Configure in Webrix
-
In Webrix, paste the Client ID and Client Secret
-
Select the scopes you need:
- At minimum:
User.Read,Mail.Read,offline_access - For sending: Add
Mail.Send - For full management: Add
Mail.ReadWrite - For mailbox settings: Add
MailboxSettings.ReadorMailboxSettings.ReadWrite
- At minimum:
-
Click Save Changes
-
Click Connect to authorize the integration
Available Scopes
Read Operations
- User.Read - Required for authentication; reads user profile information
- Mail.Read - Read access to the user's mailbox, including messages and attachments
- MailboxSettings.Read - Read mailbox settings like automatic replies, language, and time zone
Write Operations
- Mail.Send - Send emails on behalf of the user
- Mail.ReadWrite - Full read/write access to messages, drafts, and mail folders
- MailboxSettings.ReadWrite - Manage mailbox settings including automatic replies
Essential
- offline_access - Enables refresh tokens to maintain long-term access without re-authentication
Common Use Cases
Read and Search Email
- List messages from inbox or any mail folder
- Search for emails by keywords, sender, or subject
- Get full email details including body and attachments
- Filter emails by read status, importance, or other criteria
Send and Respond to Email
- Send new emails with HTML formatting to multiple recipients
- Reply to or reply-all to existing messages
- Forward emails to other recipients
- Create draft emails for later review and sending
Manage Email
- Mark messages as read or unread
- Flag messages for follow-up
- Move messages between folders (inbox, archive, etc.)
- Delete messages
- Categorize emails
Organize Folders
- List all mail folders with unread/total counts
- Create custom mail folders and subfolders
- Rename or delete folders
Configure Mailbox
- View mailbox settings (language, time zone, working hours)
- Set up automatic replies (out of office) with custom messages for internal and external senders
- Schedule automatic replies for specific date ranges
Troubleshooting
Insufficient Privileges Error
Cause: The application doesn't have the required permissions, or admin consent hasn't been granted.
Solution:
- Verify that you've added all necessary Microsoft Graph permissions in the Azure portal
- Check if any permissions require admin consent
- Ask your tenant administrator to grant admin consent
- Ensure the user authorizing the app has a valid mailbox
Cannot Send Emails
Cause: Missing Mail.Send permission or the user's mailbox is restricted.
Solution:
- Ensure the app has the
Mail.Sendpermission - Verify the user has a licensed Exchange Online mailbox
- Check if there are any transport rules blocking outbound mail
- Verify the recipient addresses are valid
Search Returns No Results
Cause: The search index may not have processed recent messages, or the query syntax is incorrect.
Solution:
- Allow a few minutes for newly received messages to be indexed
- Use simple keyword searches first before trying KQL syntax
- Check that the search query doesn't have syntax errors
- Try searching in a specific folder vs. across all folders
Access Token Has Expired
Cause: The OAuth access token has expired (typically after 1 hour).
Solution:
- Ensure
offline_accessscope is included to enable automatic token refresh - The connector should automatically refresh tokens using the refresh token
AADSTS65001: User Has Not Consented
Cause: The user hasn't consented to the requested permissions.
Solution:
- If you're an admin, grant admin consent in the Microsoft Entra admin center
- If not an admin, contact your IT administrator to grant consent
- Reduce the requested scopes to only those you need
Best Practices
Permissions
- Principle of Least Privilege: Only request the scopes your application actually needs
- Start with
Mail.ReadandMail.Send, addMail.ReadWriteonly if you need folder/draft management - Use
MailboxSettings.Readinstead ofReadWriteif you only need to view settings
Rate Limits
- Microsoft Graph has throttling limits; implement retry logic for 429 responses
- Avoid polling for new messages too frequently; consider webhooks for real-time notifications
- Use
$selectto request only the fields you need, reducing response size
Security
- Never expose client secrets in client-side code or version control
- Store access tokens and refresh tokens securely
- Rotate client secrets regularly (before they expire)
- Audit application access periodically
API Reference
This connector uses Microsoft Graph API v1.0 to interact with Outlook Mail. The base URL is https://graph.microsoft.com/v1.0.
Key endpoints used:
/me/messages- Message operations/me/mailFolders- Folder operations/me/sendMail- Send email/me/mailboxSettings- Mailbox settings
For more information, see the Microsoft Graph Mail API documentation.
Limitations
- Attachment Size: File attachments in API requests are limited to 3MB base64-encoded. For larger attachments, use upload sessions (not yet supported)
- Search Limitations: Full-text search may take a few minutes to index new messages
- Rate Limiting: Microsoft Graph API has throttling limits; the connector does not currently implement retry logic for 429 responses
- Shared Mailboxes: Accessing shared mailboxes requires additional configuration and permissions
- Batch Operations: Bulk operations are executed sequentially; no batch API support currently
Additional Resources
- Microsoft Graph Mail API
- Microsoft Graph Permissions Reference
- Outlook Mail REST API
- Microsoft Graph Explorer - Test API calls interactively