C++ & Outlook::Items - IEnumVARIANT::Clone(...) returns 0

J

Jaap

Hi,

I'm automating Outlook 2000 SR1, mainly the appointment stuff.
Because of Q294385 (which describes a problem with the Count
property returning invalid values when using IncludeRecurrences)
I wrote a simple iterator class to wrap IEnumVARIANT.
This lets me use the Items collection in a way similar to the
recommended solution (For Each in Vb) in C++.
However, to implement a copy constructor for the iterator class,
I wrote a static Clone function (included below), which should
return a cloned IEnumVARIANT instance. The Clone() call
succeeds, but yields a NULL pointer (after the call iev is empty).

Could someone confirm whether Clone is not implemented properly,
or whether I'm making some mistake ?

TIA,

JJ

// Static member IEnumIter::Clone()

template <class T> IEnumVARIANTPtr
IEnumIter<T>::Clone(const IEnumVARIANTPtr ep)
{
if(ep == 0) return 0;
IEnumVARIANT* iev;
if(SUCCEEDED(ep->Clone(&iev)))
{
IEnumVARIANTPtr result = iev;
iev->Release();
return result;
}
throw "Clone() failed";
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top