Sort Method (Folders Collection)

The Sort method sorts the collection on the specified property according to the specified sort order.

Syntax

objFoldersColl.Sort( [SortOrder] [, PropTag] )

objFoldersColl.Sort( [SortOrder] [, name] )

objFoldersColl
Required. The Folders collection object.
SortOrder
Optional. Long. The specified sort order, one of the following values:
Value Numeric value Description
CdoNone 0 No sort
CdoAscending 1 Ascending sort (default)
CdoDescending 2 Descending sort

PropTag
Optional. Long. The property tag value for the MAPI property to be used for the sort. PropTag is the 32-bit MAPI property tag associated with the property, such as CdoPR_STORE_ENTRYID.
name
Optional. String. The custom property name of a MAPI named property.

Remarks

Both parameters are optional. If SortOrder is not specified, ascending order is used. If neither PropTag nor name is specified, the property used in the previous call to Sort is used again. If Sort has never been called on this collection during this session, the MAPI property CdoPR_DISPLAY_NAME is used for the sort.

Each call to Sort generates an entirely new sort order based on the specified property. No previous sort order is retained or nested.

If the underlying messaging system does not support the sort criteria specified, for example descending order or MAPI named properties, the Sort method returns CdoE_TOO_COMPLEX.