Export Microsoft 365 emails to Excel
Connection settings, credentials and the limits that break exports — for Microsoft 365.
Connection settings
| Setting | Value |
|---|---|
| IMAP host | outlook.office365.com |
| Port | 993 |
| Encryption | SSL/TLS |
| Access | read-only |
Credentials
- 1. Request OAuth app registration from IT
- 2. Or export from Outlook desktop to PST
- 3. For IMAP, confirm basic auth is still allowed for the tenant
Limits to expect
- Conditional access policies can block IMAP entirely
- Retention policies may move messages out of the mailbox
- Audit logging applies to scripted access
Export command
python mail_to_excel.py --host outlook.office365.com --port 993 --user you@example.com --days 31 --out mail.xlsx
Next step
The universal IMAP guide · Exports by role · Ready script ($3)
FAQ
IMAP is blocked by policy
Use the desktop export or Graph API with admin consent.
Will admins see the export?
Yes, scripted access is usually logged; get approval first.
Related guides
- Universal IMAP exportThe method that works for every provider.
- Exports by roleColumns and pitfalls for 20 professions.