Platform SDK: CDO for Windows 2000

Delete Method

The Delete method deletes the specified Message object from the collection and from the file system folder.

[Visual Basic]
Sub Delete(Index as Long)
[C++]
HRESULT Delete( long Index )
[IDL]
HRESULT Delete(long Index);

Parameters

Index
The ordinal index of the Message object to delete.

Remarks

You must pass the ordinal index of the object to delete from the collection. You cannot pass an object reference.

You can use the Delete method within an enumeration because the _NewEnum property returns an enumeration of the current collection that is in the same order as the ordinal index for each object.

The Delete method also deletes the file in the file system folder opened with the DropDirectory.GetMessages object.

Example

' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
Dim iDropDir as New CDO.DropDirectory
Dim iMsgs as CDO.IMessages
Dim iMsg as CDO.Message
Dim i as Long
i = 1
Set iMsgs = iDropDir.GetMessages
For Each iMsg in iMsgs
  If iMsg.To = "someaddress" Then
   iMsgs.Delete i
  End If
  i = i + 1
Next iMsg