12

When I loading properties of multiple exchange items by ExchangeService.LoadPropertiesForItems method, Exchange skip some properties of items attachments in response:

<t:CalendarItem>
  <t:ItemId Id="itemId" ChangeKey="itemChangeKey"/>
  <t:Subject>Test appointment</t:Subject>
  <t:Attachments>
    <t:FileAttachment>
      <t:AttachmentId Id="firstAttachmentId"/>
      <t:Name>pdf.pdf</t:Name>
      <t:Size>94150</t:Size>
      <t:LastModifiedTime>2015-08-03T10:54:40</t:LastModifiedTime>
      <t:IsInline>false</t:IsInline>
      <t:IsContactPhoto>false</t:IsContactPhoto>
    </t:FileAttachment>
    <t:FileAttachment>
      <t:AttachmentId Id="secondAttachmentId"/>
      <t:Name>ATT89202</t:Name>
      <t:Size>3803738</t:Size>
      <t:LastModifiedTime>2015-12-03T16:40:46</t:LastModifiedTime>
      <t:IsInline>true</t:IsInline>
    </t:FileAttachment>
  </t:Attachments>
</t:CalendarItem>

As you can see, in response above not included ContentId property. But when I use Load method of Item class for loading properties of single item, EWS Managed API generates the same GetItem SOAP request with single item id and Exchange responding with extended set of attachments properties:

<t:CalendarItem>
  <t:ItemId Id="itemId" ChangeKey="itemChangeKey"/>
  <t:Subject>Test appointment</t:Subject>
  <t:Attachments>
    <t:FileAttachment>
      <t:AttachmentId Id="firstAttachmentId"/>
      <t:Name>pdf.pdf</t:Name>
      <t:ContentId>25F20E449DEC42B67EB3DE58C51E56E3BE0B27F5@1</t:ContentId>
      <t:Size>94150</t:Size>
      <t:LastModifiedTime>2015-08-03T10:54:40</t:LastModifiedTime>
      <t:IsInline>false</t:IsInline>
      <t:IsContactPhoto>false</t:IsContactPhoto>
    </t:FileAttachment>
    <t:FileAttachment>
      <t:AttachmentId Id="secondAttachmentId"/>
      <t:Name>ATT89202</t:Name>
      <t:ContentId>DB969CA378C5F9565E98779626E3BCA3A65FB275@1</t:ContentId>
      <t:Size>3803738</t:Size>
      <t:LastModifiedTime>2015-12-03T16:40:46</t:LastModifiedTime>
      <t:IsInline>true</t:IsInline>
    </t:FileAttachment>
  </t:Attachments>
</t:CalendarItem>

As you can see, in the second response ContentId property presented Moreover, when I use ExchangeService.LoadPropertiesForItems method, passing in single item as the first argument, Exchange also include Attachment.ContentId property into response.

Is there a way I can get ContentId properties of items attachments without loading properties for all items separately?

Yuriy Rozhovetskiy
  • 22,270
  • 4
  • 37
  • 68
  • have you tried service.LoadPropertiesForItems(items, PropertySet.FirstClassProperties);? – Kien Chu Dec 16 '15 at 04:56
  • @kienct89 yes, I tried. The same result - if there is single item in collection, Exchange responding with `ContentId` property of inline attachments. If there are more than one item passed in, `ContentId` does not returned for attachments of all items. – Yuriy Rozhovetskiy Dec 16 '15 at 08:43

1 Answers1

2

You could use ExchangeService.BindToItems method. It returns a comprehensive set of attachment properties.

See ExchangeService.BindToItems

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
cookiemonster
  • 131
  • 1
  • 5
  • The same result - ContentId property not returned – Yuriy Rozhovetskiy Dec 09 '15 at 06:57
  • Maybe you could try the [EWS GetAttachment operation](https://msdn.microsoft.com/en-us/library/office/aa494316(v=exchg.150).aspx) so you can send a list of all attachement ids you want to load together. I realize it is not exactly what you want but it beats making multiple calls for each attachment you retrieve. Hopefully it works. – cookiemonster Dec 18 '15 at 12:06