This sample has been moved to: Outlook-Add-in-JavaScript-MakeEWSRequest. The description below does not match the new version.
Old Description:
This sample accompanies the MSDN article Calling Web services from a mail app.
The JavaScript code in this sample shows a simple request for the subject of the current email message. While this is a simple request, it does demonstrate the steps required to create an EWS service request and the best practices
for making the request.
The code that creates the EWS XML request includes two methods. The first method, getSoapEnvelope(), wraps a SOAP envelope around a web service request. Because the SOAP envelope is standard for all EWS requests, this method can
be reused to wrap any EWS request.
The second method, getSubjectRequest(), returns the EWS request to get the subject field of an item. The id parameter is the Exchange item identifier for the requested item. Note the following about the request:
The sendRequest() method is called when you click the Make EWS request button in the app UI. It gets the Exchange identifier of the current item and passes it to the getSubjectRequest() and getSoapEnvelope() methods, then makes an asynchronous call to the Exchange server by using the makeEwsRequestAsync method. The makeEwsRequestAsync method takes two parameters: the EWS request wrapped in its SOAP envelope, and a callback method that is called when the asynchronous request to EWS is complete. You can add a third optional userContext parameter to the makeEwsRequestAsync method if you have to provide additional information to the callback method.
The callback() method is called with a single parameter, asynchResult. The asynchResult object has two members:
The callback method in the sample displays the contents of the response in a scrollable div element in the UI, but your code can use the response in more sophisticated ways.
This sample requires that you have the following:
The sample solution contains the following files:
The mail app will be activated on any email message in the user's Inbox. You can make it easier to test the app by sending one or more email messages to your test account before you run the sample app.
Press F5 to build and deploy the sample application. Complete the following tasks to deploy the application:
You run and test the sample in the web browser that is started by Visual Studio when you build and deploy the sample.
If you are running the sample on an Exchange server that is using the default self-signed certificate, you will receive a certificate error when the web browser starts. After you verify that the web browser is opening the correct URL by looking at the web address, you can click Continue to this Web site to start Outlook Web App.
Follow these steps to run the sample:
The following are common errors that can occur when you use Outlook Web App to test a mail app for Outlook: