none
[EWS] GetAttachment returns other Ids in response than used in the request RRS feed

  • Question

  • Hello,

    I have a problem using the Exchange WebServices to retrieve Attachments from a (journal) postbox. In my request I provide the IDs of multiple Attachments that are not neccessarily within the same e-mail. I get then a successful response but the attachments have different IDs so that I cannot connect the attachments to the right e-mails.

    Is this a bug in the Exchange Server? I use the Exchange Version 15.1.1713.5 / V2017_07_11. Strange is that this works most of the time. But sometimes the response contains different IDs.

    Here are my request and my response, content is trimmed:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Header>
        <ns2:ExchangeImpersonation xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types">
          <ns2:ConnectingSID>
            <ns2:PrimarySmtpAddress>Postbox-Journal@example.com</ns2:PrimarySmtpAddress>
          </ns2:ConnectingSID>
        </ns2:ExchangeImpersonation>
        <ns2:RequestServerVersion xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types" Version="Exchange2007_SP1"/>
      </soap:Header>
      <soap:Body>
        <GetAttachment xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/types">
          <AttachmentShape>
            <ns2:BodyType>Best</ns2:BodyType>
            <ns2:AdditionalProperties>
              <ns2:ExtendedFieldURI PropertyTag="0x300B" PropertyType="Binary"/>
            </ns2:AdditionalProperties>
          </AttachmentShape>
          <AttachmentIds>
            <ns2:AttachmentId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="AAMkAGEyOTJlMzU0LTUwZWUtNDc3MC04ZTE1LTY4YjVmMWUyYjUxMQBGAAAAAAC/joJFqIkXRafKDVM8iX/wBwDpbknHO7FhQ49g8MyiZ6fUAAAA2PWaAADJX0LVO4HsRY+jGcWYgzSCAAA20UetAAACEgAQAJ2YkUhLm6hPpxTwzkayv6USABAAwLKRE+Yxsk6P4xcouWepCw==" xsi:type="ns2:AttachmentIdType"/>
            <ns2:AttachmentId xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="AAMkAGEyOTJlMzU0LTUwZWUtNDc3MC04ZTE1LTY4YjVmMWUyYjUxMQBGAAAAAAC/joJFqIkXRafKDVM8iX/wBwDpbknHO7FhQ49g8MyiZ6fUAAAA2PWaAADJX0LVO4HsRY+jGcWYgzSCAAA2zBPYAAACEgAQAHd0ys1t0A9ArJ9YLo8Rfr0SABAABgfVQlzsb0W9Xi/334Yghw==" xsi:type="ns2:AttachmentIdType"/>
          </AttachmentIds>
        </GetAttachment>
      </soap:Body>
    </soap:Envelope>

    Response:

    <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
      <s:Header>
        <h:ServerVersionInfo xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" MajorVersion="15" MinorVersion="1" MajorBuildNumber="1713" MinorBuildNumber="5" Version="V2017_07_11"/>
      </s:Header>
      <s:Body>
        <m:GetAttachmentResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
          <m:ResponseMessages>
            <m:GetAttachmentResponseMessage ResponseClass="Success">
              <m:ResponseCode>NoError</m:ResponseCode>
              <m:Attachments>
                <t:FileAttachment>
                  <t:AttachmentId Id="AAMkAGEyOTJlMzU0LTUwZWUtNDc3MC04ZTE1LTY4YjVmMWUyYjUxMQBGAAAAAAC/joJFqIkXRafKDVM8iX/wBwDpbknHO7FhQ49g8MyiZ6fUAAAA2PWaAADJX0LVO4HsRY+jGcWYgzSCAAA20UetAAABEgAQAMCykRPmMbJOj+MXKLlnqQs="/>
                  <t:Name>a.pdf</t:Name>
                  <t:ContentType>application/pdf</t:ContentType>
                  <t:ContentId>B300EBA4BF3D684BBFFA25DB26203D8D@klinikum-os.net</t:ContentId>
                  <t:Content>JVBERi0xLjQKJeLj0YK</t:Content>
                </t:FileAttachment>
              </m:Attachments>
            </m:GetAttachmentResponseMessage>
            <m:GetAttachmentResponseMessage ResponseClass="Success">
              <m:ResponseCode>NoError</m:ResponseCode>
              <m:Attachments>
                <t:FileAttachment>
                  <t:AttachmentId Id="AAMkAGEyOTJlMzU0LTUwZWUtNDc3MC04ZTE1LTY4YjVmMWUyYjUxMQBGAAAAAAC/joJFqIkXRafKDVM8iX/wBwDpbknHO7FhQ49g8MyiZ6fUAAAA2PWaAADJX0LVO4HsRY+jGcWYgzSCAAA2zBPYAAABEgAQAAYH1UJc7G9FvV4v99+GIIc="/>
                  <t:Name>image001.jpg</t:Name>
                  <t:ContentType>image/jpeg</t:ContentType>
                  <t:ContentId>image001.jpg@01D50B2A.9BCCCD40</t:ContentId>
                  <t:Content>/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAoHBwkHBgoJCAkLCwo=</t:Content>
                </t:FileAttachment>
              </m:Attachments>
            </m:GetAttachmentResponseMessage>
          </m:ResponseMessages>
        </m:GetAttachmentResponse>
      </s:Body>
    </s:Envelope>

    Kind Regards

    Friday, May 24, 2019 1:43 PM

All replies

  • Hi,

    Exchange server forum mainly discusses and provide suggestions about Exchange server issues. Since your issue is about getting attachments from EWS items by using EWS, we will help you move this case to Exchange server development forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other forum members who read the forums regularly can either share their knowledge or learn from your interaction with us. 

    Thanks for your understanding. 

    Regards,

    Lydia Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, May 27, 2019 4:17 AM