다음을 통해 공유


_NewEnum Property (IMessages)

Topic Last Modified: 2006-06-13

Returns an IEnumVARIANT interface on an object that can be used to enumerate the collection.

Applies To

IMessages Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

HRESULT get__NewEnum(IUnknown** retval);

Parameters

  • retval
    On return, an IEnumVARIANT object reference that can be used to enumerate the collection.

Remarks

The _NewEnum property is marked restricted in the Interface Definition Language (IDL) definition for the IMessages Interface, and is not shown in the Microsoft® Visual Basic® object browser. It is automatically used internally when you use the For Each In construct in Visual Basic.

Example


#import "c:\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()
{
  CoInitialize(NULL);
  IEnumVARIANT* pEnum = 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;

  pMsgs->get__NewEnum(&pUnk);
  pUnk->QueryInterface(__uuidof(IEnumVARIANT),(void**)&pEnum);

  ULONG cFetched = 0;
  VARIANT var;
  VariantInit(&var);
  while (1) {
    cFetched = 0;
    pEnum->Next(1,&var,&cFetched);
    cout << "fetched: " << cFetched << endl;
    if(cFetched == 0)
       break;
    IMessage* pMsg = NULL;

    var.pdispVal->QueryInterface(__uuidof(IMessage),(void**)&pMsg);
    var.pdispVal->Release();
    VariantClear(&var);
    BSTR to;
    pMsg->get_To(&to);
    cout << _bstr_t(to) << endl;
    SysFreeString(to);
    pMsg->Release();

  }
  CoUninitialize();
}