问题
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