The Microsoft Exchange Server API Via EWS
Microsoft’s Exchange Web Services (EWS) provides the functionality to enable client applications to communicate with the Exchange server to access mail and calendars. If you’re looking to integrate your Exchange server calendars with Calendar.com, this post will provide the information you need to get connected as well as troubleshoot common issues.
Connecting Exchange Server
Before you can access an Exchange server calendar via the EWS API, you need to authenticate the account with the appropriate permissions. Below are some questions that you may come across while connecting the Exchange Server calendar.
Authentication method: NTLM authentication
Exchange on-premise servers support the NTLM authentication for applications that run inside the corporate firewall. First, specify your credentials. The username is usually in WINDOMAIN\username format, where WINDOMAIN is the name of the Windows Domain your username is connected to. Some servers also accept usernames in the PrimarySMTPAddress (‘email@example.com’) format (Office365 requires it). The UPN format is also supported if your server expects that.
How to find the EWS Server / URL:
For on-premise Microsoft Exchange servers:
The default URL for EWS is https://<mail-server>/ews/exchange.asmx
If using the above URL with the appropriate domain is not functional, the correct URL can be retrieved in one of two ways below.
On-premise Exchange – by an admin
1. The Exchange admin can use a PowerShell command on the exchange server
a. Open PowerShell on the Exchange server
b. Type Get-WebServicesVirtualDirectory | Select name, *url* | fl
c. The URL will be provided
On-premise Exchange – by a non-admin user
You may be able to obtain the EWS URL in a couple of ways, depending on the Exchange server configuration. Try each of the following methods in order. As soon as you get the Exchange server name, skip to the last step.
- Log into your mailbox via Outlook Web App (OWA, formerly Outlook Web Access) in your browser. Copy only the <mail-server> part from the browser’s URL https://<mail-server>/owa/ - it may be your server name.
- Logged into your OWA, go to: Options -> See All Options -> Account -> My Account and click “Settings for POP, IMAP, and SMTP access…”. Find and copy the “server name.”
- Search for “mail server” in your company intranet, the internal knowledge base, or contact your IT support.
Use the Outlook 2007 or 2010 Auto Discovery feature and do the following:
- Hold the Ctrl key and right-click on the Outlook icon in the system tray (Note this must be outlook version 2007 or 2010).
- Select "Test E-mail AutoConfiguration" from the menu.
- Type in an email address located on the desired Exchange server.
- Ensure that only the "Use Auto Discover" checkbox is enabled.
Can’t connect the Exchange Calendar?
Here are some possible reasons:
- EWS access is not enabled or blocked.
- Invalid credentials - Make sure that the credentials are given as per the Windows NTLM account.
- Auto-discovery failure - If the server URL is not provided, please check that the auto-discovery configuration has the appropriate setup.