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: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
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: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