2017-09-06 3 views
0
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()); 
} 

現在、私の取引所に接続していますが、未読メールを読み込んで添付ファイルを取得する必要があります。EWS Java Api検索フィルターが無視されました

検索フィルタは機能しませんが、OperatorをORからORに変更できます。SortDirectionを昇順から降順に変更できますが、違いはありません。私の検索フィルターは現在未読に設定されていますが、ランダムなメールが戻ってきます。 ItemViewは10に設定されていますが、157の電子メールを返します。 printlnから

:私が間違ってやっているのTotal number of items found: 157

任意の提案ですか? 親切に受け入れる

答えて

0

searchFilterCollectionからsearchFilterに変更して問題を解決し、このビューで日付の並べ替えの問題も修正されました。

FindItemsResults<Item> findResults 
         = service.findItems(WellKnownFolderName.Inbox, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false), view); 
関連する問題