Bsa.Exchange.WebServices 6.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bsa.Exchange.WebServices --version 6.0.4
                    
NuGet\Install-Package Bsa.Exchange.WebServices -Version 6.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bsa.Exchange.WebServices" Version="6.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bsa.Exchange.WebServices" Version="6.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Bsa.Exchange.WebServices" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bsa.Exchange.WebServices --version 6.0.4
                    
#r "nuget: Bsa.Exchange.WebServices, 6.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bsa.Exchange.WebServices@6.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bsa.Exchange.WebServices&version=6.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Bsa.Exchange.WebServices&version=6.0.4
                    
Install as a Cake Tool

Bsa.Exchange.WebServices

Exchange Web Services (EWS) Managed API 2.2, ported to .NET 6.

This is a drop-in replacement for the legacy Microsoft.Exchange.WebServices 2.2.0 NuGet package (2018, .NET Framework only). It is built from Microsoft's open-source code (OfficeDev/ews-managed-api, MIT). The public API is unchanged (except the removed GetUserPhotoResults.AsImage(), see below):

  • same namespace: Microsoft.Exchange.WebServices.Data
  • same assembly name: Microsoft.Exchange.WebServices.dll
  • same synchronous API (ExchangeService, Folder.Bind, FindItems, StreamingSubscription, …)

Code written for the original package should compile and run without changes.

Installation

dotnet add package Bsa.Exchange.WebServices

Target framework: net6.0. The package also works in .NET 7, 8, 9 and later projects.

If your project references Microsoft.Exchange.WebServices or Microsoft.Exchange.WebServices.NETStandard, remove that reference first. Both packages contain the same namespace.

Quick start

using System;
using Microsoft.Exchange.WebServices.Data;

var service = new ExchangeService(ExchangeVersion.Exchange2013_SP1)
{
    Credentials = new WebCredentials("user@contoso.com", "password"),
    Url = new Uri("https://mail.contoso.com/EWS/Exchange.asmx")
};

// or OAuth:
// service.Credentials = new OAuthCredentials(accessToken);

// or Autodiscover:
// service.AutodiscoverUrl("user@contoso.com", url => url.StartsWith("https://"));

Folder inbox = Folder.Bind(service, WellKnownFolderName.Inbox);
Console.WriteLine($"Inbox: {inbox.TotalCount} total, {inbox.UnreadCount} unread");

foreach (Item item in service.FindItems(WellKnownFolderName.Inbox, new ItemView(10)))
{
    Console.WriteLine($"{item.DateTimeReceived:yyyy-MM-dd HH:mm}  {item.Subject}");
}

Changes from the original 2.2 code

Area Problem on .NET 6 Fix
Safe XML readers (Security/*, EwsXmlReader) ProhibitDtd was removed from .NET Core Uses DtdProcessing.Prohibit
HangingServiceRequestBase System.Web.HttpException is not available Catch removed. On .NET 6 these errors surface as IOException or WebException, which are already handled
Streaming subscriptions The HttpClient-based response stream throws InvalidOperationException on ReadTimeout and crashed the process ReadTimeout is set only when Stream.CanTimeout is true
GetUserPhotoResults.AsImage() Required System.Drawing.Common, which is Windows-only on .NET 6+ Removed (breaking change). Use the Photo byte array with any imaging library (ImageSharp, SkiaSharp, …). The package no longer depends on System.Drawing.Common
Autodiscover via LDAP SCP System.DirectoryServices (ADSI) is Windows-only Rewritten on System.DirectoryServices.Protocols. Works on Windows and Linux/macOS with the Kerberos identity of the current process. On Linux the AD site is detected from AD subnet objects
Autodiscover via DNS SRV P/Invoke into dnsapi.dll Windows keeps dnsapi.dll. Linux and macOS use a managed resolver (DnsClient package)
X509CertificateCredentials X509Certificate2.PrivateKey is unreliable on .NET Core Uses GetRSAPrivateKey()
BasicAuthModuleForUTF8 AuthenticationManager.Register does nothing on .NET Core Now a no-op. .NET already encodes Basic credentials as UTF-8
MIME charsets Legacy code pages (windows-1251, koi8-r, …) are not registered by default CodePagesEncodingProvider is registered when the assembly loads
Assembly metadata InternalsVisibleTo pointed to internal Microsoft assemblies Removed

The library does not use WCF or System.ServiceModel. SOAP requests are built directly with HttpWebRequest and XmlWriter, as in the original.

Platform notes

  • Windows: full functionality.
  • Linux / macOS: full functionality, including Autodiscover via LDAP SCP and DNS SRV. See the requirements below.

Linux in an Active Directory domain (Kerberos)

Typical setup: a domain-joined Linux host (realmd/SSSD, krb5.conf with default_realm) and on-premises Exchange with Windows authentication on /EWS and /Autodiscover.

var service = new ExchangeService(ExchangeVersion.Exchange2013_SP1, TimeZoneInfo.FindSystemTimeZoneById("Russian Standard Time"))
{
    UseDefaultCredentials = true   // Kerberos ticket of the current user / service keytab
};
service.AutodiscoverUrl("user@contoso.com", url => url.StartsWith("https://"));
  • Native packages. LDAP: libldap (Debian/Ubuntu libldap-2.5-0 or newer, RHEL openldap). Kerberos over SASL: libsasl2-modules-gssapi-mit (RHEL cyrus-sasl-gssapi). HTTP Negotiate: libgssapi-krb5-2 (RHEL krb5-libs). NTLM fallback: gss-ntlmssp. Official mcr.microsoft.com/dotnet/* images include none of these.
  • Kerberos ticket. The process needs a valid ticket: interactive kinit, an SSSD-managed credential cache, or a keytab for a service (KRB5_CLIENT_KTNAME). Check with klist.
  • Domain controller. The AD domain is taken from default_realm in krb5.conf (or KRB5_CONFIG), then from the host FQDN, then from the e-mail domain. DCs are located through _ldap._tcp.dc._msdcs.<domain>, so the SPN ldap/<dc fqdn> matches.
  • SPN for EWS. The host name in the EWS URL must have an HTTP/<host> SPN in AD, usually registered on the Exchange alternate service account. If it is missing, Negotiate silently falls back to NTLM.
  • Time zones. Linux uses IANA IDs (Europe/Moscow), while Exchange expects Windows IDs. Pass the time zone to the ExchangeService constructor as shown above. ICU (libicu) is required, and InvariantGlobalization must stay off.
  • ADFS. ADFS-based OAuth (Exchange 2019 Modern Auth) is supported via OAuthCredentials, but this library does not obtain the token. Get it from ADFS yourself (for example, with MSAL using the ADFS authority) and pass it to new OAuthCredentials(token).

Known limitations

  • Exchange Online / Microsoft 365: Microsoft is retiring EWS. Phased disablement began on 1 October 2026, and EWS will be shut down permanently on 1 April 2027. Use Microsoft Graph for new Microsoft 365 integrations. Exchange Server on-premises is not affected, and EWS keeps working there.
  • HttpWebRequest is still used internally. It is marked obsolete (SYSLIB0014) but is fully functional on .NET 6 and later, because it runs on HttpClient.
  • The assembly is not strong-name signed with Microsoft's key. Rebuild any code that depended on the original strong name.
  • No new async API was added. The API is the original synchronous one plus the classic Begin*/End* methods.

License

MIT. Original code © Microsoft Corporation. See LICENSE.txt in the package.

Source code: https://github.com/S-DyX/Bsa.Exchange.WebServices

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.1 111 10/24/2026
9.0.1 90 10/24/2026
8.0.1 96 10/24/2026
7.0.1 100 10/24/2026
6.0.4 92 10/24/2026
6.0.3 116 10/24/2026
6.0.1 107 10/23/2026
6.0.0 97 10/23/2026
2.2.2 101 10/23/2026