---
title: "Codeunit 5321 Exchange Web Services Server"
author: "Jonas Paprotka"
url: https://jonas-paprotka.de/ref/codeunit/5321-exchange-web-services-server/
type: codeunit
id: 5321
name: "Exchange Web Services Server"
app: "Base Application"
namespace: System.Integration
versions: "17-28"
build: 28.5.54151.54365
source: "https://jonas-paprotka.de/ref/codeunit/5321-exchange-web-services-server/source/29/"
checked: 2026-09-20
subject: "Microsoft Dynamics 365 Business Central"
license: "Content © 2026 Jonas Paprotka. Quote freely with attribution and a link."
---

# Codeunit 5321 Exchange Web Services Server

Jonas Paprotka, https://jonas-paprotka.de/ref/codeunit/5321-exchange-web-services-server/

| | |
| --- | --- |
| App | Base Application |
| Namespace | System.Integration |
| Versions | 17-28 |
| Source file | System/Exchange/ExchangeWebServicesServer.Codeunit.al |

## Procedures

| Name | Parameters | Returns | Access | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- | --- |
| Initialize | (Text[250], Text, DotNet ExchangeCredentials, Boolean) | Boolean | public | 17-28 | - | - |
| InitializeAndValidate | (Text[250], var Text, DotNet ExchangeCredentials) | Boolean | public | 17-28 | - | - |
| Initialize2010 | (Text[250], Text, DotNet ExchangeCredentials, Boolean) | Boolean | public | 17-28 | - | - |
| Initialize2010WithUserImpersonation | (Text[250], Text, DotNet ExchangeCredentials, Boolean) | Boolean | public | 17-28 | - | - |
| InitializeWithCertificate | (Guid, Text[40], Text[250], Text[250], Text[250]) | - | public | 17-28 | - | - |
| InitializeWithOAuthToken | (Text, Text) | - | public | 17-27 | Pending 25.0 | Replaced by InitializeWithOAuthToken(Token: SecretText; ExchangeEndpoint: Text) |
| ValidCredentials | () | Boolean | public | 17-28 | - | - |
| SetImpersonatedIdentity | (Text[250]) | - | public | 17-28 | - | - |
| InstallApp | (InStream) | - | public | 17-28 | - | - |
| CreateAppointment | (var DotNet IAppointment) | - | public | 17-28 | - | - |
| SendEmailMessageWithAttachment | (Text, Text, Text, Text, Text) | Boolean | public | 17-28 | - | - |
| SaveEmailToInbox | (Text) | - | public | 17-28 | - | - |
| SaveHTMLEmailToInbox | (Text, Text, Text, Text, Text) | - | public | 17-28 | - | - |
| GetEmailFolder | (Text, var DotNet IEmailFolder) | Boolean | public | 17-28 | - | - |
| IdenticalMailExists | (DotNet IEmailMessage, DotNet IEmailFolder, var DotNet IEmailMessage) | Boolean | public | 17-28 | - | - |
| CompareEmailAttachments | (DotNet IEmailMessage, DotNet IEmailMessage) | Boolean | public | 17-28 | - | - |
| GetEmailAndAttachments | (Text[250], var Record Exchange Object, Option, Code[20]) | - | public | 17-22 | Pending 20.0 | Please use GetEmailAndAttachments which uses RecordRef instead of Vendor number. |
| GetEmailBody | (Text[250]) | Text | public | 17-28 | Pending 28.0 | Please use Microsoft Graph API instead e.g `Email - Outlook REST API` |
| EmailHasAttachments | (Text[250]) | Boolean | public | 17-28 | Pending 28.0 | Please use Microsoft Graph API instead e.g `Email - Outlook REST API` |
| GetEndpoint | () | Text | public | 17-28 | - | - |
| ProdEndpoint | () | Text | public | 17-28 | - | - |
| GetCurrentUserTimeZone | () | Text | public | 17-28 | - | - |
| GetEmailAndAttachments | (Text[250], var Record Exchange Object, Option, RecordRef) | - | public | 20-28 | Pending 28.0 | Please use Microsoft Graph API instead e.g `Email - Outlook REST API` |
| IsDefaultProdEndpoint | (Text) | Boolean | public | 21-28 | - | - |
| InitializeWithOAuthToken | (SecretText, Text) | - | public | 25-28 | - | - |

## Events

| Kind | Name | Parameters | Versions | Obsolete | Reason |
| --- | --- | --- | --- | --- | --- |
| Integration event | OnBeforeSaveHTMLEmailToInbox | (var Text, var Text, var Text, var Text, var Text) | 17-28 | - | - |
| Integration event | OnBeforeSendEmailMessageWithAttachment | (var Text, var Text, var Text, var Text) | 17-28 | - | - |
| Integration event | OnAfterGetProdEndpoint | (var Text) | 17-28 | - | - |

## Source

Symbols: Microsoft.BaseApplication.symbols.437dbf0e-84ff-417a-965d-ed2bb9650972, https://dynamicssmb2.pkgs.visualstudio.com/DynamicsBCPublicFeeds/_packaging/MSSymbols/nuget/v3/index.json, highest build per major on 2026-09-20.
AL source 29: https://github.com/microsoft/BCApps, MIT, releases/29.x at a66254c3b8b5bb1cea290dc8f9d097aec4381153.

Jonas Paprotka, 2026-09-20.
