Bsa.Exchange.WebServices
6.0.4
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
<PackageReference Include="Bsa.Exchange.WebServices" Version="6.0.4" />
<PackageVersion Include="Bsa.Exchange.WebServices" Version="6.0.4" />
<PackageReference Include="Bsa.Exchange.WebServices" />
paket add Bsa.Exchange.WebServices --version 6.0.4
#r "nuget: Bsa.Exchange.WebServices, 6.0.4"
#:package Bsa.Exchange.WebServices@6.0.4
#addin nuget:?package=Bsa.Exchange.WebServices&version=6.0.4
#tool nuget:?package=Bsa.Exchange.WebServices&version=6.0.4
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/Ubuntulibldap-2.5-0or newer, RHELopenldap). Kerberos over SASL:libsasl2-modules-gssapi-mit(RHELcyrus-sasl-gssapi). HTTP Negotiate:libgssapi-krb5-2(RHELkrb5-libs). NTLM fallback:gss-ntlmssp. Officialmcr.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 withklist. - Domain controller. The AD domain is taken from
default_realminkrb5.conf(orKRB5_CONFIG), then from the host FQDN, then from the e-mail domain. DCs are located through_ldap._tcp.dc._msdcs.<domain>, so the SPNldap/<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 theExchangeServiceconstructor as shown above. ICU (libicu) is required, andInvariantGlobalizationmust 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 tonew 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.
HttpWebRequestis still used internally. It is marked obsolete (SYSLIB0014) but is fully functional on .NET 6 and later, because it runs onHttpClient.- 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 | Versions 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. |
-
net6.0
- DnsClient (>= 1.8.0)
- System.DirectoryServices.Protocols (>= 6.0.2)
- System.Security.Cryptography.Xml (>= 6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.