Exchange Online EWS to Microsoft Graph Migration Kit (Python / exchangelib)
EWS in Exchange Online shuts down for good on 1 April 2027, and Microsoft's Exchange Team says there will be no exceptions after that. Since 10 October 2026, affected tenants also need an EWSAllowedAppIDs allow list: apps left off it have already lost EWS access.
exchangelib's maintainer has said there are no plans to add Graph support, and Microsoft's EWS analyzer only reads .NET code. This kit is for Python scripts, ETL jobs and syncs built on exchangelib.
What's inside:
- ews_scan.py: a read-only scanner. It finds every exchangelib use in your Python code (including aliased imports) plus raw EWS URLs, EWS Managed API references, EWS token scopes and full_access_as_app in config, PowerShell, .NET and other files. Each finding says what to move to: MIGRATE (a Graph equivalent exists, with the endpoint), GAP (on Microsoft's roadmap, with the ETA), NO_GRAPH (won't be added, such as public folder CRUD), AUTH (passwords, impersonation, token scope) or INFO. CI exit codes; never prints line contents.
- - graph_mail.py: a small Microsoft Graph client, standard library only, for the jobs exchangelib scripts usually do: read a folder with filters (common exchangelib filters translate to OData), download attachments with safe file names, send with attachments, reply, move to a folder by path, mark read, incremental sync with delta links, calendar between dates, and out-of-office. It caches tokens, refreshes on 401, backs off on 429/503/504, and retries network errors only on safe methods, so a send is never duplicated.
- - MIGRATION-GUIDE.md: exchangelib vs Graph side by side for 10 common jobs, the permission mapping, throttling (4 concurrent requests per mailbox) and Microsoft's parity-gap table.
- - ADMIN-RUNBOOK.md for the tenant admin: update EWSAllowedAppIDs safely (it's a replacement list), register the Graph app, scope it to specific mailboxes with RBAC for Applications, and remove the tenant-wide grant that otherwise overrides the scope.
- - CHECKLIST.md and 26 offline tests.
Honest limits:
- Built from Microsoft's docs as of 5 December 2026.
- - The Graph client is tested offline against a fake server, not a live tenant. Try it on a test mailbox first.
- - The PowerShell in the runbook is shown as guide snippets and wasn't run here.
- - The scanner reads text, so code that builds calls at runtime can be missed.
- - If you want a drop-in instead of native Graph code, the free ewsgraph package offers an exchangelib-compatible API on Graph.
- - Exchange Server on-premises isn't affected by this retirement.
Independent product. Not affiliated with Microsoft.