none
Sync email message Preview through Exchange ActiveSync RRS feed

  • Question

  • Hi folks,

    I am trying to get a snippet of a message from the server using Exchange ActiveSync protocol. I found  Preview (BodyPreference) element that "specifies the maximum length of the Unicode plain text message or message part preview to be returned to the client". So I expected if I set this Preview (BodyPreference) element to something like 200, I'd get 200 characters of the message that I could use as a message snippet in Preview (Body) element.

    However, when I tried that against a 2016 Microsoft Exchange Server, it didn't return anything in the Preview (Body) element, even though the message wasn't empty.

    Can you please advise what is the best way to fetch preview of the message?

    Sorry, I couldn't insert links as the form doesn't allow me to.

    Thank you,

    Nurlan

    Tuesday, April 2, 2019 2:08 PM

Answers

  • Hi Nurlan, 

    I found that our code doesn't return Preview element when the Body Type is 1 or Plain Text and there is Body Data being returned. 

    This does make sense as the result will be the same. The only difference here will be the size of data returned. TruncationSize will limit the Data value and of course, if the Type is not 1 (Plain Text), then the Preview size will be what was specified in the Preview request element. 

    I hope this answers your question.


    Best regards,
    Tom Jebo 
    Sr Escalation Engineer
    Microsoft Open Specifications Support

    Friday, April 5, 2019 7:42 PM
    Moderator

All replies

  • Hello Nurlan,

    Thank you for your question. One of our engineers will respond soon.

    Thanks,


    Jeff McCashland | Microsoft Protocols Open Specifications Team

    Tuesday, April 2, 2019 4:42 PM
    Moderator
  • Hi Nurlan, 

    What version of the ActiveSync protocol are you using (i.e. 16.1, 16.0, etc...)? Can you show the request XML that you're using to retrieve the email item? Also, if you can provide a Fiddler trace, please send email to dochelp at microsoft.com, reference the URL for this thread and my name.

    Best regards,
    Tom Jebo 
    Sr Escalation Engineer
    Microsoft Open Specifications Support

    Tuesday, April 2, 2019 8:00 PM
    Moderator
  • Hi Tom,

    Thank you for the reply. I am using Exchange ActiveSync 16.0. Here's XML of my request (decoded from WBXML):

    <?xml version="1.0" ?>
    <Sync>
        <Collections>
            <Collection>
                <SyncKey>835562910</SyncKey>
                <CollectionId>9</CollectionId>
                <GetChanges/>
                <WindowSize>100</WindowSize>
                <Options>
                    <FilterType>4</FilterType>
                    <BodyPreference>
                        <Type>1</Type>
                        <TruncationSize>500</TruncationSize>
                        <Preview>200</Preview>
                    </BodyPreference>
                </Options>
            </Collection>
            <Collection>
                <SyncKey>428076865</SyncKey>
                <CollectionId>16</CollectionId>
                <GetChanges/>
                <WindowSize>100</WindowSize>
                <Options>
                    <FilterType>4</FilterType>
                    <BodyPreference>
                        <Type>1</Type>
                        <TruncationSize>500</TruncationSize>
                        <Preview>200</Preview>
                    </BodyPreference>
                </Options>
            </Collection>
        </Collections>
        <WindowSize>100</WindowSize>
    </Sync>

    I can't provide a Fiddle trace, but I can provide you with raw payloads of the request and the response in WBXML format. I hope you'll find them useful. I've sent an email to the address you mentioned and referenced this thread and your name.

    Thanks,

    Nurlan

    Wednesday, April 3, 2019 8:00 PM
  • Thanks Nurlan, I received the XML from your EAS conversation in email and the response seems to agree with what you asked for in the request. I've responded in email as well but the Body Data elements in the response show what appear to be the same number of bytes as is reported by the server in the EstimatedDataSize elements. 

    Tom

    Thursday, April 4, 2019 4:56 AM
    Moderator
  • Thank you very much for taking a look, much appreciated.

    Sorry for not being clear. What I was expected in the response is something like this:

                <airsyncbase:Body xmlns:airsyncbase="AirSyncBase:">

                  <airsyncbase:Type>1</airsyncbase:Type>

                  <airsyncbase:EstimatedDataSize>10</airsyncbase:EstimatedDataSize>

                  <airsyncbase:Data>in inbox

    </airsyncbase:Data>

                  <airsyncbase:Preview>in inbox

    </airsyncbase:Preview>

                </airsyncbase:Body>

    Note that the body type that I requested in the request was set to 1 (TEXT), that's why, I believe, the server returned "in inbox" data as plain text. But what I was also expecting is to get is the server-formatted Preview of the message no matter why type of the body I requested.

    So I also tried requesting HTML and it indeed returned the Preview along with the HTML body.

    Does that mean that Preview is only returned when I request HTML body? Or it would return it if the Body Data didn't fit into the requested TruncationSize? What are other conditions that have to be satisfied in order for the server to return a Preview? 

    My ultimate goal is to get Previews of emails only as I don't need the actual body, so if you could advise on how to do that, that would be great.

    Sorry for silly questions, it's just I couldn't find answers for these in the documentation.

    Thank you,

    Nurlan

    Thursday, April 4, 2019 9:52 AM
  • Hi Nurlan, 

    I understand your question now. I've tested this also and I see similar results. I'm checking into our code and with our EAS team on this to verify the types that are valid for Preview or if there are other constraints. 

    Thanks for your patience.

    Tom

    Thursday, April 4, 2019 6:43 PM
    Moderator
  • Hi Nurlan, 

    I found that our code doesn't return Preview element when the Body Type is 1 or Plain Text and there is Body Data being returned. 

    This does make sense as the result will be the same. The only difference here will be the size of data returned. TruncationSize will limit the Data value and of course, if the Type is not 1 (Plain Text), then the Preview size will be what was specified in the Preview request element. 

    I hope this answers your question.


    Best regards,
    Tom Jebo 
    Sr Escalation Engineer
    Microsoft Open Specifications Support

    Friday, April 5, 2019 7:42 PM
    Moderator
  • Thank you very much Tom! That sounds like a way to get previews indeed.

    For your information, I figured I can get Previews by passing the TruncationSize to 0 -- in this case no Body Data is returned and the server will include Preview element. This worked for me in both cases when type is Plain Text or HTML.

    Regards,

    Nurlan

    Monday, April 8, 2019 12:15 PM
  • Thanks for the update Nurlan. That approach does agree with what I see in our code and the behavior as I described it. 

    Tom

    Monday, April 8, 2019 4:28 PM
    Moderator