Got exception while QueryInteface

  • Thread starter Thread starter Vinayakc
  • Start date Start date
V

Vinayakc

Hi all,

I have just seen one abrupt behaviour of Outlook. I wrote one add-in in
VC++. This add-in can work on multiple mail items at a time. Means user
can select more than one mail and thorugh add-in command bar button it
moves all mails to the specific folder.
When I selecte around 200-400 mails in one go, at any point my
queryinterface function from following code throws an exception. I
could not understand this as outlook behaves randomly. Some times it
moves all mails to that folder and sometimes it throws an exception.

Code is :
result = pSelection->Item(vIndex,&pSelectedItem);
if( result != S_OK )
{
LOG_ERR_MESSAGE( _T("Item()") , result );
bRet = FALSE;
goto Error;
}

//Get the selected mail item
result = pSelectedItem->QueryInterface(&spMailItem);
if( result != S_OK )
{
LOG_ERR_MESSAGE( _T("QueryInterface()") , result );
bRet = FALSE;
goto Error;
}


I have debugged it. When exception occurs pSelectedItem is not having
NULL value. So I am not able to understand why this happens. This
application has one more working thread which works on the mailitems
which we move to that particular folder.

Waiting for reply.

Thanks and Regards
Vinayakc
 
Outlook is running out of the 255 RPC channels/process limit when you select
a large number of items. Do you release both pSelectedItem and spMailItem in
the loop?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Yes Dmirty I have tried that also, but still exception occurs. One
thing I noticed is that I am calling move function to move the copy of
selected mails to the particular folder. If I comment that code snippet
which moves mail one by one, it works fine. I could not get why outlook
is behaving in this way.
 
Move is a function returning the new message, which your code probably
ignores and consequently never releases.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Sorry for late. First of all very happy new year to all of u.
Dmirty thanks for reply, I did not know that Move function returns one
new message. i am using it like following

result = spDupMailItem->Move(.m_MyFolder,(IDispatch * *)&pItem);
if( result != S_OK )
{
//prompt error
}

Is this a right way to move the item.
How I can release the new message which Move returns.

Thanks and Regards
Vinayakc
 
Hi Dmitry,

Thank you very much for this. this trick worked. Thank you!!

Regards
Vinayakc
 
Back
Top