Platform SDK: Exchange 2000 Server

_NewEnum Property

[This is preliminary documentation and subject to change.]

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

[Visual Basic]
(*Restricted from direct access. Used in For Each In constructs)
[C++]
HRESULT get__NewEnum(IUnknown** retval);
[IDL]
[propget, restricted, id(DISPID_NEWENUM)] HRESULT _NewEnum([out, retval] IUnknown** retval);
retval
On return, an IEnumVARIANT object reference that can be used to enumerate the collection.

Remarks

The _NewEnum property is marked restricted in the IDL definition for IMessages and is not shown in the Visual Basic object browser. It is automatically used internally when you use the For Each In construct in Visual Basic.

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