Microsoft Exchange Client

The javaxt-exchange library is used to retrieve, create, edit, and delete Email Messages, Contacts, and Calendar Events hosted on a Microsoft Exchange Server.

Microsoft Exchange Server is a mail and calendaring server developed by Microsoft. The javaxt-exchange library communicates with an Exchange Server via the Exchange Web Services API.

This project began in 2012 when there were very few open source Java projects that could work with Microsoft Exchange. Those that did exists were inflexible. They were built using code generated from a WSDL. Different versions of Exchange have different WSDLs resulting in compatibility issues.

The javaxt-exchange library overcomes these limitations by NOT using proxy classes generated from a WSDL. Instead, the javaxt-exchange library communicates directly with an Exchange server via SOAP/XML messages. This approach has proved quite resilient over the years through multiple releases of Exchange. The library has been used in production since 2012.

Download javaxt-exchange
Current Version: 1.0
Release Date: 12/10/2017
File Size: 147 KB
File Format: Zip
Includes: Jar File and Source Code

Key Features

  • Send/Recieve Email Messages
  • Create/Edit Calendar Events
  • Manage Contacts
  • Add Custom Attributes to Items
  • Intuitive API
  • Compatible with all EWS enabled Exchange Servers
  • HTTPS/SSL Support


The javaxt-exchange library leverages the javaxt-core library for HTTP requests/responses, XML parsing, and date/time management. There are no other dependancies on any other library and should work with Java 1.6 and higher.

Getting Started

The first thing you need in order to use the javaxt-exchange library is the URL to your EWS service. In my experience, the URL ends in a ".asmx" extension and the corresponding WSDL is located at the same node. Example:


Ask your provider or IT administrator if you need help.

Once you have the EWS endpoint, and a valid email account on the server, you're ready to go!

Here's an example of a simple command line application that you can test the connection to EWS. The main() method is the command line interface to the application. It is used to connect to the given mailbox on the Exchange Server and retrieve a list of root folders.

package com.example;

public class Main {

  //Entry point for the application
    public static void main(String[] args) {

      //Set connection information for the Exchange Web Services
        String url = "";
        String username = "";
        String password = "aa7mz@SC9P"; ews = new, username, password);

      //Get list of folders and print the folder name and unread message count
        String Traversal = "Shallow"; //"Deep", "Shallow", "SoftDeleted" parentFolder = new"msgfolderroot", ews);
        for ( folder : parentFolder.getFolders(Traversal)){
            System.out.println(folder.getName() + " (" + folder.getUnreadCount()+ ")");

This should yield something like this:

Conversation Action Settings (0)
Deleted Items (16806)
Drafts (4)
Files (0)
Inbox (47)
Journal (0)
Junk E-mail (252)
Notes (0)
Outbox (0)
Quick Step Settings (0)
RSS Feeds (0)
Sent Items (0)
Sync Issues (0)
Unwanted (0)
Working Set (0)
Yammer Root (0)

Test Inbox

Here's an example of how to retrieve messages from the Inbox using the EmailFolder class. Note that in this example, dates are rendered in a specific timezone. You'll need to adjust the timezone to match your application needs.

      //Set date/time formatting variables
        String dateFormat = "M/d/yyyy hh:mm a";
        String timeZone = "America/New York";

      //Get first 25 messages from the Inbox inbox = new"inbox", ews);[] messages = inbox.getMessages(0, 25, null, null, null);
        for ( message : messages){

          //Print message info
            String date = message.getDateTimeReceived().toString(dateFormat, timeZone);
            System.out.println("- " + message.getSubject() + " From: " + message.getFrom() + " on " + date);

          //If the message has a response or was forwarded, print additional metadata
            if (message.getResponse()!=null){ 
                System.out.println(" --> You " + message.getResponse() + " this message on " + 
                    message.getResponseDate().toString(dateFormat, timeZone));

Calendar Test

Here's a simple example of how to retrieve appointments from the Calendar using the CalendarFolder class.

      //Set date/time formatting variables
        String dateFormat = "M/d/yyyy hh:mm a";
        String timeZone = "America/New York"; calendarFolder = new;[] events = calendarFolder.getEvents(new javaxt.utils.Date());
        for ( event : events){
            String startTime = event.getStartTime().toString(dateFormat, timeZone);
            System.out.println(event.getSubject() + " - " + startTime + " (" + event.isAllDayEvent() + ")");

More Examples

Coming soon... In the interim, check out the docs.