![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hello, I want to creating an addin that captures when a {contact, calendar,
task, note} is {created, edited, removed}. I have the following code, to make it shorter I removed all the code but the related to contact, since all types will be the same I guess. AutoSync.h class ATL_NO_VTABLE AutoSync : public wxPanel, public IDispEventSimpleImpl1, AutoSync, &__uuidof(Outlook::ItemsEvents), public IDispEventSimpleImpl2, AutoSync, &__uuidof(Outlook::ItemsEvents), public IDispEventSimpleImpl3, AutoSync, &__uuidof(Outlook::ItemsEvents) { public: .... void __stdcall OnItemAdd(IDispatch* Item); /* 0xf001 */ void __stdcall OnItemChange(IDispatch* Item); /* 0xf002 */ void __stdcall OnItemRemove(); /* 0xf003 */ BEGIN_SINK_MAP(AutoSync) SINK_ENTRY_INFO(1, __uuidof(Outlook::ItemsEvents), 0xf001, OnItemAdd, &OnItemsAddInfo) SINK_ENTRY_INFO(2, __uuidof(Outlook::ItemsEvents), 0xf002, OnItemChange, &OnItemsChangeInfo) SINK_ENTRY_INFO(3, __uuidof(Outlook::ItemsEvents), 0xf003, OnItemRemove, &OnItemsRemoveInfo) END_SINK_MAP() typedef IDispEventSimpleImpl1, AutoSync, &__uuidof(Outlook::ItemsEvents) ItemAddEvents; typedef IDispEventSimpleImpl2, AutoSync, &__uuidof(Outlook::ItemsEvents) ItemChangeEvents; typedef IDispEventSimpleImpl3, AutoSync, &__uuidof(Outlook::ItemsEvents) ItemRemoveEvents; private: CComPtrOutlook::_Items m_contacts; }; AutoSync.cpp _NameSpacePtr pMAPI = OutlookWorker::GetInstance()-GetNameSpacePtr(); MAPIFolderPtr pContactsFolder = NULL; HRESULT hr = NULL; //get folders if(pMAPI != NULL) { pMAPI-GetDefaultFolder(olFolderContacts, &pContactsFolder); } //get items if(pContactsFolder != NULL) pContactsFolder-get_Items(&m_contacts); //dispatch events if(m_contacts != NULL) { //HERE COMES THE EXCEPTION hr = ItemAddEvents: ![]() hr = ItemChangeEvents: ![]() hr = ItemRemoveEvents: ![]() } and this defined somewhere else: _ATL_FUNC_INFO OnItemsAddInfo = {CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}}; _ATL_FUNC_INFO OnItemsChangeInfo = {CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}}; _ATL_FUNC_INFO OnItemsRemoveInfo = {CC_STDCALL,VT_EMPTY,0}; When the instructions: hr = ItemAddEvents: ![]() hr = ItemChangeEvents: ![]() hr = ItemRemoveEvents: ![]() are executed, an excetion comes in atlbase.inl' when executes method 'Advise': ATLINLINE ATLAPI AtlAdvise(IUnknown* pUnkCP, IUnknown* pUnk, const IID& iid, LPDWORD pdw) { if(pUnkCP == NULL) return E_INVALIDARG; CComPtrIConnectionPointContainer pCPC; CComPtrIConnectionPoint pCP; HRESULT hRes = pUnkCP-QueryInterface(__uuidof(IConnectionPointContainer ), (void**)&pCPC); if (SUCCEEDED(hRes)) hRes = pCPC-FindConnectionPoint(iid, &pCP); if (SUCCEEDED(hRes)) //HERE GIVES EXCEPTION //Unhandled exception at 0x2fe913e3 in OUTLOOK.EXE: 0xC0000005: //Access violation reading location 0xcdcdcdcd. hRes = pCP-Advise(pUnk, pdw); return hRes; } Any idea or suggestion here? Thank you. |
Ads |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Capturing Outlook Forms Events | Duke2 | Outlook - Using Forms | 21 | August 29th 09 03:07 AM |
Capturing Outlook Forms Events | Sue Mosher [MVP][_3_] | Outlook - Using Forms | 1 | August 28th 09 09:25 PM |
Capturing Send/Receive events in VSTO add-in | Aakash Polra | Outlook - General Queries | 1 | September 30th 08 06:49 PM |
Getting no Events ! - IDispEventSimpleImpl , DispEventAdvise | davidb | Add-ins for Outlook | 3 | June 13th 06 09:31 AM |
Capturing Message URL | Avatar | Outlook Express | 7 | January 30th 06 06:47 PM |