Link to home
Start Free TrialLog in
Avatar of whorsfall
whorsfallFlag for Australia

asked on

Exchange Folder.FindItems until end of messages.

Hi,

I am using the Microsoft.Exchange.WebServices Nuget package the process mail messages.

Here is an extract of my code:


DateTime start_date = new DateTime(2018, 7, 1); //Year, month, day
DateTime end_date = new DateTime(2019, 6, 30);
               
SearchFilter greaterthanfilter = new SearchFilter.IsGreaterThanOrEqualTo(ItemSchema.DateTimeReceived, start_date);
SearchFilter lessthanfilter = new SearchFilter.IsLessThanOrEqualTo(ItemSchema.DateTimeReceived, end_date);
SearchFilter filter = new SearchFilter.SearchFilterCollection(LogicalOperator.And, greaterthanfilter, lessthanfilter);

Folder folder = Folder.Bind(_service, WellKnownFolderName.Inbox); //Or the folder you want to search in
FindItemsResults<Item> results = folder.FindItems(filter, new ItemView(100));

Now this gets the first group.

How to i next get the next group until it ends.

In other words:

get messages

while (more_messages)
{
  get next set of messages
}

Thanks,

Ward.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial