0

我正在使用 EWS Java API(2.0 版)在 Java 中获取交换电子邮件

我想从交换框获取发送到此电子邮件地址(“rams@mydomain.com”)的所有邮件

这是我的示例代码

 String email = "rams@mydomain.com"
 ItemView itemView = new ItemView(1000);


 SearchFilter.SearchFilterCollection searchFilterCollection1 = new SearchFilter.SearchFilterCollection(
                    LogicalOperator.Or
                    );
            SearchFilter searchFilter1 = new SearchFilter.ContainsSubstring(EmailMessageSchema.DisplayCc, email);
            SearchFilter searchFilter2 = new SearchFilter.ContainsSubstring(EmailMessageSchema.DisplayTo, email);
            searchFilterCollection1.add(searchFilter1);
            searchFilterCollection1.add(searchFilter2);
            FindItemsResults<Item> items = exService.findItems(WellKnownFolderName.SentItems,searchFilterCollection1,itemView);

我没有任何例外。我没有收到任何电子邮件,但实际上电子邮件存在于服务器中。

谢谢

4

1 回答 1

0

您是否尝试过使用查询字符串查看 Participants 字段?

String email = "rams@mydomain.com";
ItemView itemView = new ItemView(1000);

var queryString = String.Format("(From:=%1$s OR Participants:=%1$s)", email);

FindItemsResults<Item> items = exService.findItems(WellKnownFolderName.SentItems, 
                                                  queryString, itemView);
于 2015-06-03T20:14:22.073 回答