Platform SDK: CDO 1.2.1

Delete Method (CDONTS Recipient Object)

The Delete method removes the Recipient object from the Recipients collection.

Syntax

objRecip.Delete( ) 
 

Remarks

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

The final Release on the Recipient 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 effect of the Delete operation is not permanent until you use the Send or Delete method on the Message object to which this recipient belongs.

The immediate parent of this Recipient object is a Recipients collection, which is a child of the message. You can delete all the message's recipients by calling the collection's Delete method.

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.

Example

This code fragment illustrates the two situations previously explained. The Set statement calls AddRef on the first Recipient object. That reference survives the call to Delete and has to be reassigned. The second Recipient object is deleted without creating another reference, and no other action is necessary.

' assume valid Message object 
Set objRecip = objMessage.Recipients.Item(1) 
objRecip.Delete ' still have a reference from Set statement 
' ... other operations on objRecip possible but pointless ... 
Set objRecip = Nothing ' necessary to remove reference 
' ... 
objMessage.Recipients.Item(2).Delete ' no reference to remove