7

When reading items from an Exchange mailbox, I'd like to be explicit in that they're picked up in order that they were received (datetime received) - earliest first.

How can I specify (on the ItemView?) the sort value(s), and sort direction?

using Microsoft.Exchange.WebServices.Data;

var service = new ExchangeService();
var inbox = new FolderId(WellKnownFolderName.Inbox);
var iv = new ItemView(500);

//how to specify sorting, if possible?

var items = service.FindItems(inbox, iv);
if (items.TotalCount > 0)
{
}

Using the Exchange Managed Web Services.

p.campbell
  • 98,673
  • 67
  • 256
  • 322

1 Answers1

18

This example on MSDN shows how to use the OrderBy property of ItemView to sort results:

   iv.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173
reuben
  • 3,360
  • 23
  • 28