none
OWA - Accessing e-mails based on CAS log information RRS feed

  • Question

  • Is there a way to access each individual e-mail based on a line in the CAS log? For example, if the IPM.Note in the part of the URI query string says an e-mail was read, I would like to know which specific e-mail was read.

     

    Would this link be relevant?

     

    http://social.technet.microsoft.com/Forums/en/exchangesvrdevelopment/thread/09accc1d-e5cc-4f84-850a-08adc4edefb4

     

    Thanks in advance.

    Monday, January 31, 2011 6:26 PM

Answers

  • You can use Exchange Web Services to convert the OWAid from the log into a EWSID then bind to the Item and find out what you want eg using the EWS managed API

    String owaString = "AAAAAAypzpcBPm9CiyX4nncV2NYHA...";
    AlternateId[] ai = new AlternateId[1];
    ai[0] = new AlternateId();
    ai[0].UniqueId = owaString;
    ai[0].Format = IdFormat.OwaId;
    ai[0].Mailbox = "blah@blah.com";
    ServiceResponseCollection<ConvertIdResponse> cvtresp = service.ConvertIds(ai, IdFormat.EwsId);
    EmailMessage em = EmailMessage.Bind(service, ((AlternateId)cvtresp[0].ConvertedId).UniqueId);
    Console.WriteLine(em.Subject);
    

     

    Cheers
    Glen

    • Marked as answer by jpvi Monday, February 7, 2011 5:15 PM
    Tuesday, February 1, 2011 2:32 AM
  • You can use anything that can send and recieve SOAP message in regards to using EWS i would however suggest that you look at using the EWS Managed API which is what i've used in that code sample i posted this greatly simplifies things. The operation you need to use to convert and id is the convertid operations see http://msdn.microsoft.com/en-us/library/bb799665(v=exchg.140).aspx

    Cheers
    Glen

    • Marked as answer by jpvi Monday, February 7, 2011 5:15 PM
    Friday, February 4, 2011 1:11 AM

All replies

  • You can use Exchange Web Services to convert the OWAid from the log into a EWSID then bind to the Item and find out what you want eg using the EWS managed API

    String owaString = "AAAAAAypzpcBPm9CiyX4nncV2NYHA...";
    AlternateId[] ai = new AlternateId[1];
    ai[0] = new AlternateId();
    ai[0].UniqueId = owaString;
    ai[0].Format = IdFormat.OwaId;
    ai[0].Mailbox = "blah@blah.com";
    ServiceResponseCollection<ConvertIdResponse> cvtresp = service.ConvertIds(ai, IdFormat.EwsId);
    EmailMessage em = EmailMessage.Bind(service, ((AlternateId)cvtresp[0].ConvertedId).UniqueId);
    Console.WriteLine(em.Subject);
    

     

    Cheers
    Glen

    • Marked as answer by jpvi Monday, February 7, 2011 5:15 PM
    Tuesday, February 1, 2011 2:32 AM
  • Do I have to write a .Net app to do this call or can I just query the Exchange Web Services to get the e-mail message? Also, if I do have to write a .Net app, which APIs do I need to use in order to make the correct calls?
    Wednesday, February 2, 2011 6:06 PM
  • You can use anything that can send and recieve SOAP message in regards to using EWS i would however suggest that you look at using the EWS Managed API which is what i've used in that code sample i posted this greatly simplifies things. The operation you need to use to convert and id is the convertid operations see http://msdn.microsoft.com/en-us/library/bb799665(v=exchg.140).aspx

    Cheers
    Glen

    • Marked as answer by jpvi Monday, February 7, 2011 5:15 PM
    Friday, February 4, 2011 1:11 AM
  • OK, so managed to send a receive a SOAP message and got the proper EwsId. Now it seems that I need to use the GetItem call in order to get the actual e-mail message. I tried passing the EwsLegacyId to GetItem, but apparently you also need the ChangeKey value. I left the ChangeKey value empty in the GetItem SOAP request. Is there any way to get the ChangeKey by passing SOAP messages? Does it make a different that I'm passing EwsLegacyId instead of EwsId?

     

    Here is the error response I get:

     

    <?xml version="1.0" encoding="utf-8"?>

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <soap:Header>

    <t:ServerVersionInfo MajorVersion="8" MinorVersion="3" MajorBuildNumber="137" MinorBuildNumber="0" xm
      lns:t="http://schemas.microsoft.com/exchange/services/2006/types" />

    </soap:Header>

    <soap:Body>

    <m:GetItemResponse xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"

      xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages">

    <m:ResponseMessages><m:GetItemResponseMessage ResponseClass="Error">

    <m:MessageText>The change key is invalid.</m:MessageText><m:ResponseCode>ErrorInvalidChangeKey</m:ResponseCode>

    <m:DescriptiveLinkKey>0</m:DescriptiveLinkKey>

    <m:Items />

    </m:GetItemResponseMessage>

    </m:ResponseMessages>
    </m:GetItemResponse>

    </soap:Body>

    </soap:Envelope>

    Wednesday, February 9, 2011 8:48 PM
  • No you dont need to specifed the Change key but if you have included it in the request even if its set blank you will get this type of error.

    Cheers
    Glen

    Thursday, February 10, 2011 2:10 AM
  • Yeah, I ended up just taking the ChangeKey parameter out of the request and it worked out.
    Thursday, February 10, 2011 9:32 PM