Freigeben über


GetAttachment doesn't get Size of the attachment

For those, who don't use Exchange Web Services API, but bank on its Requests and Responses.

An email message has a attachment table that contains the attachments, and these in turn contain the properties such as PR_ATTACH_SIZE, PR_ATTACH_DATA_BIN etc. This means that email message doesn't have any of the attachment properties on it.

The GetItem could be used to get the all the properties of an email message, the extended properties being got by PathToExtendedFieldType.

The GetAttachment doesn't get the PR_ATTACH_SIZE MAPI Property when being given the Attachment ID. The size could be found by using the Length property of the Content fetched in the byte array.

This is also validated with PathToExtendedFieldType, which when usen in GetAttachment request doesn't send back the PR_ATTACH_SIZE.
GetAttachmentType getAttachmentRequest = new GetAttachmentType(); getAttachmentRequest.AttachmentShape = new AttachmentResponseShapeType(); PathToExtendedFieldType pteftFlagStatus = new PathToExtendedFieldType(); pteftFlagStatus.PropertyTag = "0x0E20"; // Tag of PR_ATTACH_SIZEpteftFlagStatus.PropertyType = MapiPropertyTypeType.Long;

REQUEST
<?xml version="1.0"?>
  <GetAttachmentType xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema">
    <AttachmentShape xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <AdditionalProperties xmlns="https://schemas.microsoft.com/exchange/services/2006/types">
        <ExtendedFieldURI PropertyTag="0x0E20" PropertyType="Long" />
      </AdditionalProperties>
    </AttachmentShape>
    <AttachmentIds xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
    <AttachmentId Id="AAAaAEFkbWluaXN0cmF0b3JAZGMxMjkw...</AttachmentIds>
</GetAttachmentType>

RESPONSE
<?xml version="1.0"?>
  <GetAttachmentResponseType xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema">
    <ResponseMessages xmlns="https://schemas.microsoft.com/exchange/services/2006/messages">
      <GetAttachmentResponseMessage ResponseClass="Success">
        <ResponseCode>NoError</ResponseCode>
          <Attachments>
           <FileAttachment xmlns="https://schemas.microsoft.com/exchange/services/2006/types">
             <AttachmentId Id="AAAaAEFkbWluaXN0cmF0b3JAZG...<Name>smime.p7m</Name>
                 <ContentType>multipart/signed</ContentType>
                   <Content>TUlNRS1WZXJza.....
                   </Content>
           </FileAttachment>
          </Attachments>
      </GetAttachmentResponseMessage>
    </ResponseMessages>
</GetAttachmentResponseType>

There we go. The response doesn't yield the Extended Field type property.
Hence, the theorem.