Delete Method (CDONTS Attachments Collection)

The Delete method removes all the Attachment objects from the Attachments collection.

Syntax

collAttachments.Delete( ) 
 

Remarks

The Delete method performs an irreversible operation on the collection. It calls Release on the collection's reference to every Attachment object. If you have another reference to an attachment, 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 attachment.

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

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

The effect of the Delete method is not permanent until you use the Send or Delete method on the Message object containing the Attachments collection. A permanently deleted member cannot be recovered. However, the collection itself is still valid, and you can Add new members to it.

The CDO for NTS Library does not permit any modifications to messages in the Inbox, other than deleting the entire message. Prohibited modifications include adding, deleting, or modifying any attachment; adding, deleting, or modifying any recipient; and modifying any message property, even one with read/write access.