Attachments with the ReferenceAttachment type ( ATTACH_BY_WEB_REF) from O365 mailbox are not returned using EWS

流过昼夜 提交于 2021-02-08 11:34:36

问题


I have a mailbox on Exchange 365 and when I share a picture from OneDrive using the Share as OneDrive Link, then the attachment is not returned using the latest EWS API. The list of attachments is simple empty although the HasAttachments property is true. The fallback for this type of attachment (ATTACH_BY_WEB_REF) should be a FileAttachment but the list is empty.

I did some tests with both MFCMApi and EWSEditor and here are the results:

  • EWSEditor (in case when the file is shared as Onedrive Link ) is showing HasAttachment as true but when you want to load the table of attachments- it comes up empty.
  • MFCMapi- I've achieved this by adding the O365 mailbox to my Outlook profile and opening it via MFCMapi. It is showing HasAttachments as true and is able to read the attachment and it's correct ATTACH_BY_WEB_REF type
  • The Graph API correctly shows the attachment

For some reason EWS is unaware of this attachment type in some scenarios. I tried the latest EWS API and the one directly coming from Glen's github as well-with the same result (following this article: https://gsexdev.blogspot.com/2015/05/working-with-referance-attachments-in.html).This was an expected result though, as his unofficial EWS managed API is adding the implementation the ReferenceAttachment. Without this the fallback type should be FileAttachment, but in my scenario there is nothing returned.

An interesting fact is that the mentioned misbehavior is happening only for O365 account and in OWA. When the email is drag and dropped to Outlook 2016 (the O365 account was opened in Outlook and the email was drag and dropped to a different mailbox on 2016 or 2019 on-prem Exchange ) then it's repaired and I'm able to read the attachments using EWS

When I add another (but regular) file attachment, then EWS returns only the file attachment, not the one shared from OneDrive.

EDIT:

OWA isn't behaving quite the regular way attachment-wise. The fact about the email containing a ReferenceAttachment is shown only in the reading pane, the Item list is not showing a preview about it:

If I add a simple FileAttachment as well to the email, then only the FileAttachment is showing up in the item list:

Looks like that OWA is using a special logic finding out about the ReferenceAttachments- maybe is analyzing the HTML body of the email which is containing info about thatOwaReferenceAttachments, OwaReferenceAttachmentDescription, OwaReferenceAttachmentFileName2

EDIT 2:

I have uploaded the EWS Trace from an example where only one OneDrive link is in the email: http://s000.tinyupload.com/index.php?file_id=09396538471147694985

and with 2 attachments(onedrive + file attachment): http://s000.tinyupload.com/index.php?file_id=82527468863185263035

Any help is appreciated here...


回答1:


I can reproduce the problem against an Office 365 mailbox in OutlookSpy - IMessage shows two attachments (one png and the one the actual attachment) and GetItem in EWS only shows the png.

Sounds like an Exchange bug...



来源:https://stackoverflow.com/questions/65806240/attachments-with-the-referenceattachment-type-attach-by-web-ref-from-o365-mai

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!