Delete Method (IMessages)
Topic Last Modified: 2006-06-13
Deletes the specified Message object in the collection and from the file system.
Applies To
Type Library
Microsoft CDO for Exchange 2000 Library
DLL Implemented In
CDOEX.DLL
Syntax
Sub Delete( Index As Long)
HRESULT Delete
(
long Index
);
Parameters
- Index
The ordinal index of the Message object to delete.
Return Value
Returns S_OK if successful, or an error value otherwise.
Remarks
You must pass the ordinal index of the object in the collection to delete. You cannot pass an object reference.
You can use the Delete method within an enumeration successfully because the _NewEnum property returns an enumeration of the current collection in the same order as the ordinal index for each object.
The Delete method also deletes the file on the file system used to create the Message object.
Example
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