Delete Method (Messages Collection)

Delete Method (Messages Collection)

The Delete method removes all the AppointmentItem, MeetingItem, GroupHeader, and Message objects from the Messages collection.

Syntax

objMsgColl.Delete( )

Remarks

The Delete method performs an irreversible operation on the collection. It calls Release on the collections reference to every AppointmentItem, GroupHeader, MeetingItem, and Message object. If you have another reference to an object, you can still access its properties and methods, but you can never again associate it with any collection because the Add method always creates a new object. You should Set your reference variable either to Nothing or to another object.

The final Release on each AppointmentItem, GroupHeader, MeetingItem, or Message object takes place when you assign your reference variable to Nothing, or when you call Delete if you had no other reference. At this point the object is removed from memory. Attempted access to a released object results in an error return of CdoE_INVALID_OBJECT.

The Delete method does not move any MeetingItem or Message objects to the Deleted Items folder. If this folder exists and you wish this functionality, you must specifically program your application for it.

If the Messages collection underlies a categorized view, the GroupHeader objects are also removed from the collection, but unlike the messages they are not moved anywhere. Group headers do not persist in storage, and when the collection is released, whether with messages or not, the GroupHeader objects cease to exist.

Be cautious using the Delete method with a collection, because it deletes all the collections member objects. To delete only one Message object, use the Delete method specific to that object.

The Delete method on a large collection takes effect immediately and is permanent. A deleted member cannot be recovered. However, the collection itself is still valid, and you can Add new members to it.

See Also

Concepts

Messages Collection Object