Share via


Delete Method (IBodyParts)

Topic Last Modified: 2006-06-13

Removes the specified BodyPart object from the collection.

Applies To

IBodyParts Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

Sub Delete(    Item As Variant)
HRESULT Delete
(
        VARIANT Item
);

Parameters

  • Item
    Either the ordinal index or the IBodyPart interface on the object to remove from the collection.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

You can delete the object by specifying its position in the collection, or by passing the IBodyPart interface to the Delete method.

You cannot use the Delete method to delete an attachment after sending a message if the message did not contain a body. When you send a message containing an attachment without specifing a body, the attachment gets promoted, becoming the single (root) bodypart contained in the message. You can, however, delete the attachment prior to sending the message, when the attachment has not yet been promoted.

Example

Dim iMsg as New CDO.Message
Dim iBp as IBodyPart
Dim iBps as IBodyParts
Set iBps = iMsg.BodyPart.BodyParts
Set iBp = iBps.Add

' Add more body parts.
... 

' Delete this specific object.
iBps.Delete iBp
  
' Delete object #2.
iBps.Delete 2