Share via


Count Property

Count Property

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Returns the number of Message objects contained in the collection. This property is read-only.

Applies To

IMessages Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

[Visual Basic]Property Count As Long

[C++]HRESULT get_Count(longpVal);

Parameters

  • pVal
    Returns the value of the Count property as a reference to a long.

Remarks

The Count property returns the number of objects in the collection. The indexes for the objects in the collection range from 1 to Count.

The collection is not automatically updated when new messages arrive in the directory used to retrieve the Messages collection. Count only returns the number of Message objects currently in the collection, and not the number of messages that actually reside on the file system at any given time. To update the collection, you need to call the IDropDirectory GetMessages Method again and retrieve a new collection.

Examples

[Visual Basic]

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

[C++]

#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(); }

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.