Read email headers in Outlook Web Access (OWA)

℡╲_俬逩灬. 提交于 2019-11-30 16:06:39

问题


I am developing a outlook Web App (Office 365 Developer). Regarding that, is there a way to read the headers of the selected mail which lays on inbox?. I am using Exchange server 2013. I would like to use Jquery or Javascript for write the code.

I tried to add "Message Header Analyzer" from Microsoft ( link:- 'https://store.office.com/message-header-analyzer-WA104005406.aspx?assetid=WA104005406'). Now it is working properly and it can read headers. But I need to implement the same functionality using my own codes.

If anyone can provide a good reference as a start, I would greatly appreciated that. (because, I got a great effort in searching google. But.. still no luck)

thanks in advance.


回答1:


First of all, I would like to thank all the persons who responded me to develop a solution for the this. Special thanks should goes to @FreeAsInBeer and MrPiao. After spending several days I was lucky to develop a perfect solution for getting mail headers (My Tech-lead helped me a lot in this). This works fine. I got some time and removed all the unnecessary business logic from the code and finally come up with the following code. I think now any one can use it for reading the headers of inbox emails using J Query.

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

I hope this explanation will help 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 () {
            app.initialize();
            _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="http://www.w3.org/2001/XMLSchema-instance" xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
    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
    console.log(asyncResult);
}

Thank You. Kushan Randima



来源:https://stackoverflow.com/questions/26092938/read-email-headers-in-outlook-web-access-owa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!