Sort Tables after Setting Columns and Restrictions

When you need to limit the view of a sorted table, always make the following IMAPITable calls in the following order:

  1. IMAPITable::SetColumns to define the column set.
  2. IMAPITable::Restrict to impose the restriction.
  3. IMAPITable::SortTable to perform the sort.

If the sorted table is categorized, make a call to SetCollapseState if necessary after the SortTable call. This ordering of calls is important because most service providers sort a table as the last task to achieve the best performance. If, for example, a message store provider must categorize a folder contents table before a restriction can be imposed, this categorization will be removed during the processing of the restriction. A second categorization will be necessary.