Share via


GetFirst Method (Messages Collection)

GetFirst Method (Messages Collection)

The GetFirst method returns the first AppointmentItem, GroupHeader, MeetingItem, or Message object in the Messages collection. It returns Nothing if no first object exists.

Syntax

Set objMessage = objMsgColl.GetFirst( [filter] )

objMessage

On successful return, represents the first AppointmentItem, GroupHeader, MeetingItem, or Message object in the collection.

objMsgColl

Required. The Messages collection object.

filter

Optional. String. Specifies the message class of the object, such as IPM.Note, the default value. Corresponds to the Type property of the Message object.

Remarks

If the filter parameter is set, the GetFirst method returns the first meeting or message in the collection with a Type property matching the value of filter. However, if the Messages collection is in a calendar folder, the filter parameter is not supported. Microsoft® Outlook® ignores any setting of filter and returns the first appointment, while Microsoft® Schedule+ returns CdoE_TOO_COMPLEX if filter is set.

The Get methods normally return a Message object but can also return an AppointmentItem, GroupHeader, or MeetingItem object.

The order that items are returned by GetFirst, GetLast, GetNext, and GetPrevious depends on whether they are sorted or not. The AppointmentItem, GroupHeader, MeetingItem, and Message objects within a collection can be sorted on a MAPI property of your choice, either ascending or descending, using the Sort method. When the items are not sorted, you should not rely on these methods to return the items in any specified order. The best programming approach to use with unsorted collections is to assume that the access functions are able to access all items within the collection, but that the order of the objects is not defined.

The Get methods sometimes perform more efficiently if you have applied a MessageFilter object to the collection.

See Also

Concepts

Messages Collection Object