Search code examples
exchangewebservices

EWS API: how to retrieve modification date for an attachment


I want to retrieve an attachment from EWS API. Unfortunately GetAttachment by default does not return Modification Date for an attachment.

My EWS API SOAP request:

<?xml version="1.0" encoding="UTF-8"?>
        <soap:Envelope
            xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
            xmlns:t="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">
            <soap:Header>
                <t:RequestServerVersion Version="Exchange2013_SP1" />
                <t:ExchangeImpersonation>
                    <t:ConnectingSID>
                        <t:PrimarySmtpAddress>%1%</t:PrimarySmtpAddress>
                    </t:ConnectingSID>
                </t:ExchangeImpersonation>
            </soap:Header>
            <soap:Body>
                <m:GetAttachment>
                    <m:AttachmentShape />
                    <m:AttachmentIds>
                        <t:AttachmentId Id="%2%" />
                    </m:AttachmentIds>
                </m:GetAttachment>
            </soap:Body>
        </soap:Envelope>

Is it possible to get Modifitation Date from EWS API? How can I do it? Thank you.


Solution

  • Yes this is possible. You have the correct GetAttachment operation, but firstly you need to get the message and the attachment collection to get the AttachmentId of the attachment to retrieve.

    Use the GetItem operation to do this. The GetItemResponse message will then include the LastModifiedTime property your looking for.

    See Get an attachment from an email by using EWS