C
Chris
Hi,
I found this article about catching outlook events:
http://www.codeproject.com/internet...vent#xx635951xx
With this code you can catch the event, when a new mail is in the inbox.
It works fine !
I would like to catch an events when a new contact is saved or when a new appointment was created.
Theres´s no way for me to do this !
The problem is, that the FindConnectionPoint returns an error for the ItemEvents ConnectionPoint.
This is my code, which is same as in the article but only changed to the ContactItem.
//In the dialog class
1. ItemEvents m_OutlookContact;
2. //Add an event handler for the Application object.
m_pAppEventListener = new CAppEventListener();
m_pAppEventListener->AddRef();
m_pAppEventListener->AttachToSource
( m_OutlookContact.m_lpDispatch );
//In the cpp class where the EventListener is defined
STDMETHODIMP CAppEventListener::AttachToSource
( IUnknown* pEventSource )
HRESULT hr = S_OK;
IConnectionPointContainer* pCPC = NULL;
hr = pEventSource->QueryInterface( IID_IConnectionPointContainer,
(void**)&pCPC );
if (SUCCEEDED(hr)){
hr = pCPC->FindConnectionPoint( IID_ItemEvents,&m_pConnectionPoint);
if (SUCCEEDED(hr)){
hr = m_pConnectionPoint->Advise( this, &m_dwConnection );
}
pCPC->Release();
}
return hr;
}
//In the header class of the event listener I defined the item events from
the outlook typ libraries (OLE/COM Object Viewer)
const IID IID_ItemEvents=
{0x0006303A,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x0
0,0x00,0x00,0x46}};
Why is &m_pConnectionPoint : 0x00000000 ?
Only when I change the IID_ItemEvents to the IID_ApplicationEvents, which is
{0x0006304E,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x0
0,0x00,0x00,0x46}}
the function returns OK.
Can someone help me please ?
PS: When someone need the whole code to give an answer I can send it.
I found this article about catching outlook events:
http://www.codeproject.com/internet...vent#xx635951xx
With this code you can catch the event, when a new mail is in the inbox.
It works fine !
I would like to catch an events when a new contact is saved or when a new appointment was created.
Theres´s no way for me to do this !
The problem is, that the FindConnectionPoint returns an error for the ItemEvents ConnectionPoint.
This is my code, which is same as in the article but only changed to the ContactItem.
//In the dialog class
1. ItemEvents m_OutlookContact;
2. //Add an event handler for the Application object.
m_pAppEventListener = new CAppEventListener();
m_pAppEventListener->AddRef();
m_pAppEventListener->AttachToSource
( m_OutlookContact.m_lpDispatch );
//In the cpp class where the EventListener is defined
STDMETHODIMP CAppEventListener::AttachToSource
( IUnknown* pEventSource )
HRESULT hr = S_OK;
IConnectionPointContainer* pCPC = NULL;
hr = pEventSource->QueryInterface( IID_IConnectionPointContainer,
(void**)&pCPC );
if (SUCCEEDED(hr)){
hr = pCPC->FindConnectionPoint( IID_ItemEvents,&m_pConnectionPoint);
if (SUCCEEDED(hr)){
hr = m_pConnectionPoint->Advise( this, &m_dwConnection );
}
pCPC->Release();
}
return hr;
}
//In the header class of the event listener I defined the item events from
the outlook typ libraries (OLE/COM Object Viewer)
const IID IID_ItemEvents=
{0x0006303A,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x0
0,0x00,0x00,0x46}};
Why is &m_pConnectionPoint : 0x00000000 ?
Only when I change the IID_ItemEvents to the IID_ApplicationEvents, which is
{0x0006304E,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x0
0,0x00,0x00,0x46}}
the function returns OK.
Can someone help me please ?
PS: When someone need the whole code to give an answer I can send it.