Outlook 2003 COM Add-in giving access violation error

K

Kumar

Hello all,

I am writing a COM Add-in for outlook to move those messages contains
spam text.
I am studying MSGdump2000 source code, the example program works fine
in utlook 2000 and Outlook XP but in Outlook 2003 the program gives
Access violation error in this line of following sample code.

m_pConnection->Advise(static_cast<IDispatch*>(this), &m_dwCookie);


//
// sample code
//
Outlook::MAPIFolderPtr pInbox =
g_pNameSpace->GetDefaultFolder(Outlook::eek:lFolderInbox);
if( pInbox != NULL )
{
Outlook::_ItemsPtr pItems = pInbox->GetItems();
if( NULL != pItems )
{
m_pInboxItemsCollectionEventHandler = new
CItemsCollectionEventHandler();
m_pInboxItemsCollectionEventHandler->SinkEvents(pItems);
}
}


void CItemsCollectionEventHandler::SinkEvents(Outlook::_ItemsPtr
pItemsCollection)
{
HRESULT hr;
DebugTrace( DEBUG_TRACE_DETAILED,
"CItemsCollectionEventHandler::SinkEvents\n" );

// Get server's IConnectionPointContainer interface.
IConnectionPointContainer* pCPC;
hr = pItemsCollection->QueryInterface(IID_IConnectionPointContainer,
(void **)&pCPC);
if (SUCCEEDED(hr)) {

// Find connection point for events we're interested in.
hr = pCPC->FindConnectionPoint(__uuidof(Outlook::ItemsEvents),
&m_pConnection);
if (SUCCEEDED(hr))
{
m_pConnection->Advise(static_cast<IDispatch*>(this), &m_dwCookie);
m_pCollection = pItemsCollection;
}
// Release the IConnectionPointContainer
pCPC->Release();
}
}


Can anyone help me to solve this problem.

Thank you,
Kumar
 

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