Share via


GetPrevious Method (Messages Collection)

GetPrevious Method (Messages Collection)

The GetPrevious method returns the previous AppointmentItem, GroupHeader, MeetingItem, or Message object in the Messages collection. It returns Nothing if no previous object exists, for example if already positioned at the beginning of the collection.

Syntax

Set objMessage = objMsgColl.GetPrevious( )

objMessage

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

objMsgColl

Required. The Messages collection object.

Remarks

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.

If a Messages collection has not been enumerated since it was initialized, the behavior of the GetPrevious method is not defined. A collection is enumerated when you call its GetFirst method, access a member through its Item property, or use its Filter property to specify a message filter. Some providers may return CdoE_CALL_FAILED if you call GetPrevious before the collection is enumerated.

Calling GetPrevious on an unenumerated collection can produce unexpected results if the collection is reinitialized with a Set statement in every iteration of a loop. The recommended procedure is to Set an explicit variable for the collection before entering the loop. For more information, see Object Collections.

Microsoft Schedule+ does not support GetPrevious on a Messages collection of AppointmentItem objects.

See Also

Concepts

Messages Collection Object