EWS 托管 API - 忽略会议请求

EWS Managed API - Ignore Meeting Requests

使用 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);

会议请求将有一个不同的 ItemClass,因此您可以只在客户端过滤它们(我会这样做),或者创建一个 SearchFilter 以仅 return 个 ItemClass 为 [=12] 的项目=](但是这样你可能会错过一些项目)。