NewInspector method help

G

Guest

I want to add a button in the email item when the user opens the email Item
using outlook.
I read in this mailing list that ,
"An email item only exists within an Outlook data store (Exchange store or
PST file). Opening an item using Outlook would fire the NewInspector method
of the Inspectors collection. If an email was saved to the file system and
opened using some other program somehow Outlook code wouldn't know about that"

************************************************************
I tried it with the help of code project example in
"http://www.codeproject.com/atl/MS_Outlook_Addin.asp" which says,

Our add-in class should implement the InspectorEvents to track them, so add
this line in the Implements part:

CAddin : public
IDispEventSimpleImpl<1,CAddin,&__uuidof(Outlook::InspectorsEvents)>

The job is made simpler by
typedef IDispEventSimpleImpl</*nID =*/ 1,CAddin,
&__uuidof(Outlook::InspectorsEvents)> MyInspectorsEvents;

Add it in the Sink Entry:
BEGIN_SINK_MAP(CAddin)
SINK_ENTRY_INFO(1, __uuidof(Outlook::InspectorsEvents),
/*dispid*/ 0xf001, NewInspector, &OnInspectorInfo)

The OnInspector function is an external function which is going
to hold the information about our Inspector Function, and is written as
extern _ATL_FUNC_INFO OnInspectorInfo;

NewInspector is our actual function which will be invoked when a
New Inspector event occurs.
From our Application Object, we get the Inspectors object:
spApp->get_Inspectors(&spInspectors);

Finally, advise the Inspector event:
HRESULT hr=MyInspectorsEvents::DispEventAdvise((IDispatch*)spInspectors);

The event function info is as follows:
_ATL_FUNC_INFO OnInspectorInfo ={CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}};

The event function is as follows:
void __stdcall CAddin::NewInspector(IDispatch* pdispInspector)
{
AfxMessageBox("New Inspector Event Occured");
}
************************************************************
The addin is getting connected but then i am not getting the NewInspector
event.Actually the DispEventAdvise is returning the error
-2147220992(CONNECT_E_NOCONNECTION). How to solve this?
I tried to read from msdn but in that all examples are given in VB.
Thanks a lotz in Advance.
 

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