【问题标题】:EWS Java Api search filter ignoredEWS Java Api 搜索过滤器被忽略
【发布时间】:2017-09-06 18:32:31
【问题描述】:
PropertySet itempropertyset = new PropertySet(BasePropertySet.FirstClassProperties);
itempropertyset.setRequestedBodyType(BodyType.Text);

ItemView view = new ItemView(10);
view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Descending);
view.setPropertySet(new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived));
SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false));
FindItemsResults<Item> findResults = service.findItems(WellKnownFolderName.Inbox, searchFilter, view);

service.loadPropertiesForItems(findResults, itempropertyset);
System.out.println("Total number of items found: " + findResults.getTotalCount());

for (Item item : findResults) {
    System.out.println(item.getSubject());
    System.out.println(item.getBody());
}

目前在我连接到我们的交易所的应用程序中,我的要求是阅读未读邮件并获取附件。

但是搜索过滤器不起作用,我可以将 Operator 从 OR 更改为 AND,我可以将 SortDirection 从 Ascending 更改为 Descending,但这没有区别。我的搜索过滤器当前设置为未读,但它会带回随机电子邮件。 ItemView 设置为 10,但带回 157 封电子邮件。

来自 println:Total number of items found: 157

关于我做错了什么有什么建议吗? 亲切的问候

【问题讨论】:

    标签: java exchangewebservices


    【解决方案1】:

    通过将searchFilterCollection 更改为searchFilter 并添加视图解决了问题,这也解决了日期排序问题。

    FindItemsResults<Item> findResults
                            = service.findItems(WellKnownFolderName.Inbox, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false), view);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多