c# - `The property Hashtags is valid only for Exchange Exchange2015 or later versions.' 当 `EmailMessage.Bind` 时

标签 c# outlook exchangewebservices outlook-addin hashtag

我的 Outlook 加载项使用 Office.js 获取 EWS token 并将其发送到后端进行绑定(bind)以获取所需的信息。

ExchangeService service = new ExchangeService();
                service.Url = new Uri(mailItem.ewsUrl);
                service.Credentials = new OAuthCredentials(mailItem.ewsToken);
                _email = EmailMessage.Bind(service, new ItemId(mailItem.itemID));
                return _email;

但是,我收到此行抛出的错误 _email = EmailMessage.Bind(service, new ItemId(mailItem.itemID));

问题是当我使用 EmailMessage.Bind(service, new ItemId(mailItem.itemID)); EWS 会将所有 FirstClassProperties 加载给我(其中一些)我不需要它)有一种方法可以只返回 FirstClassProperties

的有限字段

最佳答案

当我调用_email = EmailMessage.Bind(service, new ItemId(mailItem.itemID)); EWS 将返回一组预定义的属性 FirstClassProperties。 尽管 hashtag 不属于 FirstClassProperties,但该调用以某种方式尝试检索该字段。因此,我不会加载一堆我不需要的东西,而是只要求那些我需要的东西。

PropertySet ps = new PropertySet(
                                                ItemSchema.Subject,
                                                ItemSchema.InReplyTo,
                                                ItemSchema.Body,
                                                ItemSchema.DateTimeSent,
                                                ItemSchema.DisplayTo,
                                                ItemSchema.Importance,
                                                EmailMessageSchema.From,
                                                ItemSchema.UniqueBody, 
                                                ItemSchema.MimeContent, 
                                                ItemSchema.HasAttachments, 
                                                ItemSchema.Attachments
                                                );
_email = EmailMessage.Bind(service, new ItemId(mailItem.itemID),ps);

关于c# - `The property Hashtags is valid only for Exchange Exchange2015 or later versions.' 当 `EmailMessage.Bind` 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52573779/

相关文章:

exchange-server - 如何在 MS Exchange 2013 中捕获 session 创建的事件

c# - 如何使用 Web api2 在 asp.net MVC 中制作异步和等待方法

c# - Razor 无法删除动态模板 dll 文件并破坏文件系统

java - 是否可以从 java 创建 TNEF 文件?

outlook - 我可以在 Outlook 中添加自定义/电子邮件域列吗?

c# - 从 exchange 服务器读取外出办公室供其他用户使用 C#

c# - ASP.net 5.0 - Web API 授权 &ErrorCode 302 而不是 401

c# - 如何判断是鼠标选中还是按键选中?

c# - Outlook VSTO - 当我调用 appointment.Display() 时如何显示 "Invite attendees"文本框?

outlook - 各种 Ews/Outlook 项目的文件扩展名是什么?