BestPaid guides · .NET · Microsoft 365

EWS deprecation in Exchange Online: how to move EWS code to Microsoft Graph before April 1, 2027

Exchange Web Services (EWS) in Exchange Online started being switched off in October 2026. It goes tenant by tenant: after a 7-day warning in the Message Center, Microsoft blocks EWS in tenants still on the default setting, and apps that use it stop working. An admin can switch it back on for listed apps, but only until April 1, 2027. From that day EWS is fully and permanently disabled for every tenant, and Microsoft says there will be no exceptions. Here is how to find what still uses EWS and move it to Microsoft Graph.

Checked against Microsoft's documentation on November 19, 2026.

Sources: Microsoft's EWS deprecation page (updated October 23, 2026), the Exchange Team posts Your Time is Almost Up (updated October 27, 2026), EWS Deprecation Is Here (updated October 26, 2026) and EWS application stopped working (October 21, 2026), Microsoft Learn Control access to EWS (updated October 7, 2026), and the EWS to Graph API mappings. This page is our own summary; follow Microsoft's documentation for every detail. EWS in Exchange Server on-premises is not being retired.

1. Find everything that still uses EWS

grep -rIl --include='*.cs' --include='*.vb' --include='*.csproj' --include='*.vbproj' \
  --include='*.ps1' --include='*.psm1' --include='*.py' --include='*.config' --include='*.json' \
  -e 'Microsoft.Exchange.WebServices' -e 'Exchange.asmx' -e 'ExchangeService(' -e 'exchangelib' .

For C# code, Microsoft's EWS Analyzer (a code analyzer for Visual Studio and VS Code) lists the EWS operations it calls. That list is your migration backlog.

2. EWS stopped working? Re-enable it until April 1, 2027

Microsoft first posts a warning in the Message Center 7 days ahead, then a post along the lines of "EWS has been disabled in your tenant". Apps that use EWS may keep asking for a username and password, or report that the EWS protocol is not available. Code that calls EWS gets HTTP 403 Forbidden with an X-EWS-Policy-Reason header: EWS is disabled for this user or tenant means EWSEnabled is off for the organization or the mailbox; EWS is blocked by policy for this user or tenant means the app ID allow list or a user-agent policy blocks the app.

A tenant admin can switch EWS back on in Baseline security mode in the Microsoft 365 admin center, or in Exchange Online PowerShell:

Get-OrganizationConfig | Fl EWSEnabled
Set-OrganizationConfig -EWSEnabled $true

With EWSEnabled set to $true, only the app IDs in EwsAllowedAppIDs can use EWS, and an empty list blocks every app. Where Microsoft switched EWS off itself, it first filled that list from the previous 60 days of usage, so a job that runs rarely can be missing. Add a missing app in Baseline security mode (Exclude specific apps) or in PowerShell. The setting takes a comma-separated list and replaces the whole list, so include the IDs already on it:

Get-OrganizationConfig -RetrieveEwsOperationAccessPolicy | Fl EwsAllowedAppIDs
Set-OrganizationConfig -EwsAllowedAppIDs "<IDs already on the list>,<your app's client ID>"

An EWSEnabled change usually applies within an hour, sometimes up to four; a change to the allow list takes up to 24 hours. Microsoft also documents Set-OrganizationConfig -EWSEnabled $null, which ignores the allow list and lets every app use EWS again until the final shutdown. Either way it is a bridge, not a fix: on April 1, 2027 tenant admins lose these settings and EWS is fully disabled.

3. Register an Entra app and scope its Microsoft Graph permissions

Most server-side EWS code signs in as a service account with impersonation, or with the EWS-only full_access_as_app permission. With Graph you register an app in Microsoft Entra ID instead:

Don't also consent the same permission tenant-wide in Entra ID. A permission consented there covers every mailbox in the tenant, and Exchange adds the two grants together, so the scope stops limiting anything. Changes take 30 minutes to 2 hours to apply; Test-ServicePrincipalAuthorization shows the result right away.

4. Replace ExchangeService with GraphServiceClient

Before, with the EWS Managed API:

var service = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
{
    Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx"),
    Credentials = new OAuthCredentials(accessToken),
    ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "orders@contoso.com")
};
var unread = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false);
FindItemsResults<Item> items = service.FindItems(WellKnownFolderName.Inbox, unread, new ItemView(50));

After, with the Microsoft Graph SDK for .NET (packages Microsoft.Graph 5.x or 6.x and Azure.Identity), inside an async method:

using System;
using System.Collections.Generic;
using Azure.Identity;
using Microsoft.Graph;
using Microsoft.Graph.Models;

var credential = new ClientCertificateCredential(tenantId, clientId, certificate);
var graph = new GraphServiceClient(credential, new[] { "https://graph.microsoft.com/.default" });

var page = await graph.Users["orders@contoso.com"].MailFolders["inbox"].Messages.GetAsync(r =>
{
    r.QueryParameters.Filter = "receivedDateTime ge 2026-11-01T00:00:00Z and isRead eq false";
    r.QueryParameters.Orderby = new[] { "receivedDateTime desc" };
    r.QueryParameters.Select = new[] { "id", "subject", "from", "receivedDateTime", "hasAttachments" };
    r.QueryParameters.Top = 50;
});

var pages = PageIterator<Message, MessageCollectionResponse>.CreatePageIterator(graph, page, m =>
{
    Console.WriteLine($"{m.ReceivedDateTime} {m.Subject}");
    return true; // keep paging
});
await pages.IterateAsync();

The mailbox you used to impersonate is now simply graph.Users["address"]. Graph pages its results, so a loop that relied on one big ItemView has to follow the next links, which PageIterator does for you.

5. EWS Managed API calls and their Microsoft Graph equivalents

EWS Managed APIMicrosoft Graph SDK (v5 and v6)
FindItems(folder, filter, view)Users[u].MailFolders["inbox"].Messages.GetAsync(...) with Filter, Select, Top
EmailMessage.Bind(service, id)Users[u].Messages[id].GetAsync()
message.SendAndSaveCopy()Users[u].SendMail.PostAsync(body) with SaveToSentItems = true
item.Move(folderId)Users[u].Messages[id].Move.PostAsync(new MovePostRequestBody { DestinationId = "archive" }) (namespace Microsoft.Graph.Users.Item.Messages.Item.Move)
message.IsRead = true; message.Update(...)Users[u].Messages[id].PatchAsync(new Message { IsRead = true })
FileAttachment.Load()Users[u].Messages[id].Attachments.GetAsync(), then FileAttachment.ContentBytes
Load ItemSchema.MimeContentUsers[u].Messages[id].Content.GetAsync() returns the MIME stream
SyncFolderItems, pull notificationsUsers[u].MailFolders["inbox"].Messages.Delta.GetAsDeltaGetResponseAsync()
StreamingSubscription, push notificationsSubscriptions.PostAsync(new Subscription { ... }) plus a webhook
FindAppointments with CalendarViewUsers[u].CalendarView.GetAsync(...) with StartDateTime and EndDateTime
GetUserAvailabilityUsers[u].Calendar.GetSchedule.PostAsGetSchedulePostResponseAsync(...)
GetUserOofSettings / SetUserOofSettingsUsers[u].MailboxSettings: read it, or update it with a PATCH
ConvertIdUsers[u].TranslateExchangeIds.PostAsTranslateExchangeIdsPostResponseAsync(...)

Sending mail:

await graph.Users["orders@contoso.com"].SendMail.PostAsync(new Microsoft.Graph.Users.Item.SendMail.SendMailPostRequestBody
{
    Message = new Message
    {
        Subject = "Your order has shipped",
        Body = new ItemBody { ContentType = BodyType.Html, Content = html },
        ToRecipients = new List<Recipient> { new Recipient { EmailAddress = new EmailAddress { Address = "customer@example.com" } } }
    },
    SaveToSentItems = true
});

6. Notifications and sync

var next = new Microsoft.Graph.Users.Item.MailFolders.Item.Messages.Delta.DeltaRequestBuilder(storedDeltaLink, graph.RequestAdapter);
var changes = await next.GetAsDeltaGetResponseAsync();
// process changes.Value, follow changes.OdataNextLink, then store changes.OdataDeltaLink

7. The traps that break migrations quietly

8. What Graph will never do

Microsoft has confirmed three EWS capabilities that won't be added to Microsoft Graph:

Microsoft's roadmap targets other gaps for late 2026, such as full-fidelity import and export for archive mailboxes, public folders and group mailboxes, access to in-place archives, and creating non-draft messages from MIME. Capabilities missing from that roadmap shouldn't be expected before EWS is fully disabled. If your app reads or writes items in one of the three places above, plan a redesign, for example a shared mailbox or SharePoint instead of a public folder; backup and migration tools may get by with the import and export APIs once they ship.

9. PowerShell scripts: from EWS to Microsoft Graph PowerShell

Scripts that load Microsoft.Exchange.WebServices.dll move to the Microsoft Graph PowerShell SDK:

Connect-MgGraph -ClientId $appId -TenantId $tenantId -CertificateThumbprint $thumbprint
Get-MgUserMailFolderMessage -UserId orders@contoso.com -MailFolderId inbox `
    -Filter "isRead eq false" -Top 50 -Property id,subject,receivedDateTime
Move-MgUserMessage -UserId orders@contoso.com -MessageId $id -DestinationId archive

10. Python scripts that use exchangelib

exchangelib talks to Exchange Web Services, so scripts built on it stop reaching Exchange Online mailboxes when EWS is switched off there. Port them to the Microsoft Graph SDK for Python (msgraph-sdk) with a certificate credential from azure-identity:

import asyncio
from azure.identity.aio import CertificateCredential
from msgraph import GraphServiceClient

async def main():
    credential = CertificateCredential(tenant_id, client_id, "app-cert.pem")
    graph = GraphServiceClient(credential, scopes=["https://graph.microsoft.com/.default"])
    page = await graph.users.by_user_id("orders@contoso.com").mail_folders.by_mail_folder_id("inbox").messages.get()
    for m in page.value:
        print(m.received_date_time, m.subject)

asyncio.run(main())
No time to move every app and script before April 1, 2027? We migrate EWS code to Microsoft Graph at a fixed price, one pull request or patch per step. Email us the EWS operations of one app for a free estimate, or book a $490 audit of your whole tenant with a fixed quote within 3 business days after we get access.
See the EWS to Graph migration offer