Platform SDK: CDO for Windows 2000 |
The Count property returns the number of Message objects contained in the collection.
[Visual Basic] Property Count as Long read-only [C++] HRESULT get_Count(long* pVal); [IDL] HRESULT [propget] Count([out,retval] long* pVal);
The Count property returns the number of objects in the collection. The index values for the objects in the collection range from 1 to Count.
The collection is not automatically updated when new messages arrive in the file system folder. To update the collection, you need to call the IDropDirectory.GetMessages method again and retrieve a new collection.
' 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 Dim C as Long i = 1 Set iMsgs = iDropDir.GetMessages C = iMsgs.Count For i = 1 to C Set iMsg = iMsgs.Item(i) If iMsg.To = "someaddress" Then iMsgs.Delete i End If Next i
#import "d:\program files\common files\system\ado\msado15.dll" no_namespace raw_interfaces_only #import <cdosys.dll> no_namespace raw_interfaces_only #include <iostream.h> void main(int argc, char* argv[]) { CoInitialize(NULL); IDropDirectory* pDropDir = NULL; IMessages* pMsgs = NULL; IMessage* pMsg = NULL; CoCreateInstance( __uuidof(DropDirectory), NULL, CLSCTX_SERVER, __uuidof(IDropDirectory), (void**)&pDropDir)); pDropDir->GetMessages(L"",&pMsgs); long count = 0; pMsgs->get_Count(&count); cout << count << endl; for(long i = 1;i<=count;i++) { pMsgs->get_Item(i,pMsg)); BSTR szTo; pMsg->get_To(&szTo); if(_bstr_t(szTo) == _bstr_t("someaddress")) pMsgs->Delete(_variant_t((long)i)); SysFreeString(szTo); } CoUninitialize(); }