【问题标题】:EWS Managed API - Ignore Meeting RequestsEWS 托管 API - 忽略会议请求
【发布时间】:2017-05-12 09:14:35
【问题描述】:

使用 EWS API 使用以下代码从邮箱中检索未读邮件。它也在检索会议请求(或邀请)。有没有办法忽略这些类型的电子邮件?

//search filter to get unread email
var searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));

//count of unread emails to retrieve
var view = new ItemView(50) { PropertySet = new PropertySet(PropertySet.IdOnly) };

//properties to return in the result set
var propertySet = new PropertySet {
    ItemSchema.Subject,
    ItemSchema.Body,
    ItemSchema.HasAttachments,
    ItemSchema.DateTimeReceived };

//order the search results by the DateTimeReceived in asc order
view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Ascending);

//set the traversal to shallow - shallow is the default option other options are Associated and SoftDeleted
FindItemsResults<Item> findResults;

do {
    //get emails from Inbox using search filter, view and retrieve properties defined above
    findResults = exchangeService.FindItems(WellKnownFolderName.Inbox, searchFilter, view);
    if (findResults.Items.Count > 0)
    {
        //do stuff
    }
    view.Offset += findResults.Items.Count;
} while (findResults.MoreAvailable);

【问题讨论】:

    标签: exchangewebservices ews-managed-api


    【解决方案1】:

    会议请求将具有不同的 ItemClass,因此您可以在客户端过滤它们(我会这样做)或创建一个 SearchFilter 以仅返回 ItemClass 为 IPF.Note 的项目(但是您可能会错过一些物品以这种方式)。

    【讨论】:

    • 你能举个例子吗?我将如何在客户端进行过滤?
    • 您需要做的就是将 ItemSchema.ItemClass 添加到属性集,然后在 //do stuff 部分查看 ItemClass 属性的值以确定您处理的项目类型。 EWS 托管 API 还返回键入的项目,所以您为什么不检查项目类型,例如 if(Item is EmailMessage) 等(会议邀请将是 MeetingRequest)。在让别人为你写代码之前,你应该先自己尝试一下,即使你写的东西不起作用,这也是他们学习的方式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-12
    • 2012-04-16
    • 2015-12-20
    • 1970-01-01
    相关资源
    最近更新 更多