使用EWS不会返回O365邮箱中具有ReferenceAttachment类型(ATTACH_BY_WEB_REF)的附件 [英] Attachments with the ReferenceAttachment type ( ATTACH_BY_WEB_REF) from O365 mailbox are not returned using EWS

查看:90
本文介绍了使用EWS不会返回O365邮箱中具有ReferenceAttachment类型(ATTACH_BY_WEB_REF)的附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Exchange 365上有一个邮箱,当我使用共享为OneDrive链接从OneDrive中共享图片时,则不会使用最新的EWS API返回附件.尽管HasAttachments属性为true,但附件列表简单为空.这种类型的附件(ATTACH_BY_WEB_REF)的后备选项应该是FileAttachment,但列表为空.

我同时使用MFCMApi和EWSEditor进行了一些测试,结果如下:

  • EWSEditor(如果文件作为Onedrive Link共享)显示HasAttachment为true,但是当您要加载附件表时-它变为空.
  • MFCMapi-我已通过将O365邮箱添加到我的Outlook配置文件并通过MFCMapi打开它来实现.它显示HasAttachments为true,并且能够读取附件,并且是正确的ATTACH_BY_WEB_REF类型
  • Graph API正确显示附件

由于某些原因,EWS在某些情况下不知道此附件类型.我尝试了最新的EWS API,也尝试了直接来自Glen的github的API,结果相同(以下文章:

如果我还向电子邮件中添加了一个简单的FileAttachment,则在项目列表中仅显示FileAttachment:

看起来OWA正在使用一种特殊的逻辑来查找有关ReferenceAttachments的信息-可能正在分析电子邮件的HTML正文,其中包含有关 OwaReferenceAttachments,OwaReferenceAttachmentDescription,OwaReferenceAttachmentFileName2

我从电子邮件中仅一个OneDrive链接的示例上传了EWS跟踪:

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...

解决方案

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...

这篇关于使用EWS不会返回O365邮箱中具有ReferenceAttachment类型(ATTACH_BY_WEB_REF)的附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆