Reading email headers in Outlook Web Access (OWA)

I am developing Outlook Web App (Office 365 Developer). Regarding this, is there a way to read the headers of the selected mail that are in the Inbox. I am using Exchange Server 2013. I would like to use Jquery or Javascript to write the code.

I tried to add the "Message Header Analyzer" from Microsoft (link: - ' '). Now it works fine and it can read headers. But I need to implement the same functionality using my own codes.

If someone can provide a good link as a starter, I'd really appreciate it. (because I put a lot of effort in google search. But .. still no luck)



source to share

1 answer

First of all, I would like to thank all the individuals who responded to me to develop a solution for this. Special thanks go to @FreeAsInBeer and MrPiao. After spending a few days, I was fortunate enough to come up with the perfect solution for getting email headers (Tech-Lead helped me a lot on this). This works great. I got some time and removed all unnecessary business logic from the code and finally came up with the following code. I think now anyone can use it to read the headers of Inbox emails using J Query.

I am making an EWS request outside to get the headers. From this callback method, I can get the expected result. Afterwards, it's better to use jQuery.parseXML to read and process the response (which is not included in the code)

Hope this explanation helps you.

var _mailbox;
var _ItemId1

(function () {
    "use strict";
    // The Office initialize function must be run each time a new page is loaded
    Office.initialize = function (reason) {
        $(document).ready(function () {
            _mailbox = Office.context.mailbox;
            _ItemId1 = _mailbox.item.itemId;         

function getSelectedEmailHeaders() {
    // Wrap an Exchange Web Services request in a SOAP envelope.
    var var1 = '<?xml version="1.0" encoding="utf-8"?>';
    var var2 = '<soap:Envelope xmlns:xsi="" xmlns:m="" xmlns:t="" xmlns:soap="">';
    var var3 = '  <soap:Header>';
    var var4 = '    <t:RequestServerVersion Version="Exchange2010" />';
    var var5 = '  </soap:Header>';
    var var6 = '  <soap:Body>';
    var var7 = '    <m:GetItem>';
    var var8 = '      <m:ItemShape>';
    var var9 = '        <t:BaseShape>IdOnly</t:BaseShape>';
    var var10 = '        <t:AdditionalProperties>';
    var var11 = '          <t:FieldURI FieldURI="item:Subject" />';
    var var12 = '          <t:FieldURI FieldURI="item:MimeContent" />';
    var var13 = '        </t:AdditionalProperties>';
    var var14 = '      </m:ItemShape>';
    var var15 = '      <m:ItemIds>';
    var var16 = '         <t:ItemId Id="' + _ItemId1 + '" />';
    var var17 = '      </m:ItemIds>';
    var var18 = '    </m:GetItem>';
    var var19 = '  </soap:Body>';
    var var20 = '</soap:Envelope>';

    var envelopeForHeaders = var1 + var2 + var3 + var4 + var5 + var6 + var7 + var8 + var9 + var10 + var11 + var12 + var13 + var14 + var15 + var16 + var17 + var18 + var19 + var20;
    //Calling EWS
    _mailbox.makeEwsRequestAsync(envelopeForHeaders, callbackForHeaders);

//This Function called when the EWS request is complete.
function callbackForHeaders(asyncResult) {
    //Write the content of the asyncResult on console


Thank. Kushan Randima



All Articles