D
DarkJem
Hi,
I'm currently trying to modify the treatment executed when a user
opens a mail in Outlook (perform security check, get attachments
informations...).
I'm working in C++/ATL to build a COM Add-In.
I'm trying to handle the Open Event on my MailItem but I can't get it
work.
I use the following code :
On top of my addin.h I have :
extern _ATL_FUNC_INFO OnSimpleEventInfo;
I declared :
public IDispEventSimpleImpl<3,CAddin, &__uuidof(Outlook::ItemEvents)>,
protected void __stdcall OpenHandler();
I added this entry in my SINK MAP:
SINK_ENTRY_INFO(3,__uuidof(Outlook::ItemEvents),
/*dispinterface of open
event*/0xf003,OpenHandler,&OnSimpleEventInfo)
typedef IDispEventSimpleImpl</*nID =*/ 3,CAddin,
&__uuidof(Outlook::ItemEvents)> ItEvents;
Then I advise the event in the OnConnection method
ItEvents:ispEventAdvise((IDispatch*)spItem,&__uuidof(Outlook::ItemEvents));
where spItem is declared as CComPtr<Outlook::_Items>
and unadvise it in the ondisconnection :
ItEvents:ispEventUnadvise((IDispatch*)spItem);
And then in addin.cpp I have :
_ATL_FUNC_INFO OnSimpleEventInfo = {CC_STDCALL,VT_EMPTY,0};
void __stdcall CAddin::OpenHandler()
{
MessageBoxW(NULL,L"Opening mail",L"Open Window",MB_OK);
}
There it is. And I get absolutely no message box when I open a mail or
any kind of stuff in Outlook. I don't know why this does not work.
My spItem object is not initialized (I don't know how to initialize it
:-|).
Is it a possible cause?
I did the same with the FolderSwitch Event and it works, I get my
message box each time I change of folder.
Any help or information would be very welcome.
Thanks
Best Regards
Jeremie
I'm currently trying to modify the treatment executed when a user
opens a mail in Outlook (perform security check, get attachments
informations...).
I'm working in C++/ATL to build a COM Add-In.
I'm trying to handle the Open Event on my MailItem but I can't get it
work.
I use the following code :
On top of my addin.h I have :
extern _ATL_FUNC_INFO OnSimpleEventInfo;
I declared :
public IDispEventSimpleImpl<3,CAddin, &__uuidof(Outlook::ItemEvents)>,
protected void __stdcall OpenHandler();
I added this entry in my SINK MAP:
SINK_ENTRY_INFO(3,__uuidof(Outlook::ItemEvents),
/*dispinterface of open
event*/0xf003,OpenHandler,&OnSimpleEventInfo)
typedef IDispEventSimpleImpl</*nID =*/ 3,CAddin,
&__uuidof(Outlook::ItemEvents)> ItEvents;
Then I advise the event in the OnConnection method
ItEvents:ispEventAdvise((IDispatch*)spItem,&__uuidof(Outlook::ItemEvents));
where spItem is declared as CComPtr<Outlook::_Items>
and unadvise it in the ondisconnection :
ItEvents:ispEventUnadvise((IDispatch*)spItem);
And then in addin.cpp I have :
_ATL_FUNC_INFO OnSimpleEventInfo = {CC_STDCALL,VT_EMPTY,0};
void __stdcall CAddin::OpenHandler()
{
MessageBoxW(NULL,L"Opening mail",L"Open Window",MB_OK);
}
There it is. And I get absolutely no message box when I open a mail or
any kind of stuff in Outlook. I don't know why this does not work.
My spItem object is not initialized (I don't know how to initialize it
:-|).
Is it a possible cause?
I did the same with the FolderSwitch Event and it works, I get my
message box each time I change of folder.
Any help or information would be very welcome.
Thanks
Best Regards
Jeremie