Weird problem with Outlook and Exchange Server

L

Luc

Hi!

If I loop though a folder that contains many items (like 150 and
up), my app will either hang, or it will loop infinitely. Say, there
are 2000 items, it will go well for the first 12 items, then it will
loop pass the 2000 items, like going to 23425253. I don't have
Exchange Server so I can't debug that problem.

It runs fine when Outlook isn't using Exchange Server... Anyone ever
experienced that problem? Here's some code:

CComPtr<Outlook::_Items> pItems

....

pItems->get_Count( &lCount );

for(INT i=lCount;i>0;i--)
{
CComPtr<IDispatch> pDisp = NULL;

vCnt = i;

pItems->Item( vCnt, &pDisp );

if( pDisp )
{

CComPtr<Outlook::_MailItem> pMailItem = NULL;

if( SUCCEEDED( pDisp->QueryInterface( IID_MailItem,
(void**)&pMailItem ) ) )
{
ATLASSERT( pMailItem );

if( pMailItem )
{
if( !reg.m_bSomething )
{
if( DoSomething( pMailItem, FALSE ) )
{
nNb++;
}
}
}

pMailItem->Close( olDiscard );
}
}
}


But would anyone have an example of how to loop through the items of
an Outlook folder that is safe with and without Exchange Server?
VC++, C#, VB, it doesn't matter, it's all good!

Thanks!
 

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