easyEWS.js for Outlook Add-ins

If you have done any work with Outlook Add-ins using the Office JavaScript API’s, you might have found a nifty function that allows you to poll the Exchange Server using EWS calls. The function: makeEwsRequestAsync(). However, this function is not the easiest thing to use. You have to formulate an EWS SOAP message that you send to the service. Getting those correct, writing the code for them, and processing the results are a real beast. But, even worse is finding exactly how to formulate the SOAP message from the existing documentation. It is something I personally did NOT look forward to as I was working on my customers solutions.

My frustration is your benefit (I hope). I created a JavaScript class called easyEws, that makes certain calls very easy. I posted the project on GitHub (previously, I had posted this on CodePlex):


I have attempted to make the functions a lot easier to use. Here are a few examples:

This code will get you the folder ID for the Drafts folder:

[code language=”javascript”]
easyEws.getFolderId("drafts", function (value) {
app.showNotification("Drafts folder ID: " + value);


Or, this example which will connect to the Inbox and tell you how many items are there:

[code language=”javascript”]
easyEws.getFolderId("inbox", function (folderId) {
easyEws.getFolderItemIds(folderId, function (arrayOfIDs) {
app.showNotification("There are " + arrayOfIDs.length + " items.");

easyEWS has the following commands that encapsulates the makeEwsRequestAsync() calls and the SOAP messages:

  • expandGroup: one dimensional expansion of a group (does not do groups within group expansions).
  • findConversationItems: returns a list of mail items that all share the same conversationId.
  • getEwsHeaders: gets a list of X-Headers in the mail message.
  • getFolderId: returns the folder ID for a named folder, like “Drafts”, “Inbox”, etc.
  • getFolderItemIds: returns a list of mail item IDs in a given folder.
  • getFolderProperty: gets a named property from a folder.
  • getMailItem: returns a mail item from the given Id.
  • updateEwsHeader: Updated the named x-header in the message.
  • updateFolderProperty: Updates the property of a folder by the given ID.


3 thoughts on “easyEWS.js for Outlook Add-ins”

  1. Thanks for posting this. I want to get the email body. Office.js ‘s method getAsync does not work with outlook 2013 window client. I tried using easyEWS.js’s getMailItem but body comes null. Can you please suggest how to read body of email?

    1. According to the documentation, it should be supported in Office 2013:
      This says you must support 1.3 for getAsync() on body. Outlook 2013 for Windows supports, 1.1, 1.2, 1.3. So, if it is not working then it may be:
      1) your coercion type is wrong. Look at the documentation and try both “Text” and “Html” and see which on you get back.
      2) the message is RMS protected somehow or is signed and you technically have no body text, everything is an attachment
      3) there is something wrong with the client / version
      Does it work from OWA or Office 365 Outlook Online? If it still does not work, then it is an issue with the message or something is not set right in your code. You can post you code and I can look it over. Otherwise, if it does work online, just not the client, then I would begin to believe there is an issue with the client.

Leave a Reply