Sort Method (Messages Collection)

Sort Method (Messages Collection)

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

Syntax

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

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

objMsgColl

Required. The Messages 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_MESSAGE_CLASS.

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_MESSAGE_DELIVERY_TIME 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 Messages collection was instantiated by a CDO rendering application, a view has been applied to the folder and the collection is already sorted on the property or properties specified by the view.If the Messages collection is in a calendar folder, the AppointmentItem objects are already sorted on CdoPR_START_DATE and cannot be sorted on any other property. An attempt do so when running with Microsoft® Outlook® returns CdoE_TOO_COMPLEX. Any call to Sort in a calendar folder when running with Microsoft Schedule+ returns CdoE_NO_SUPPORT. MeetingItem objects, however, can be sorted just like Message objects.

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.

See Also

Concepts

Messages Collection Object