handle outlook COM events when it is run with /embedding switch




I am developing outlook 2003 add-in on C++ and faced the following issue:
when the outlook is the default mail client in the internet explorer and I try sending the html page from ie (through the file->send menu) , the outlook inspector window don't contain the toolbar which is appended by my add-in on OnNewInspector notification. (I examined that outlook is running with the -Embedding parameter/switch in this case).
If I run the outlook in normal mode (run outlook.exe and than click on 'create' button in order to open inspector window) everything works fine and inspector window contains my toolbar.
Add-in implements TExtensibility2,InspectorsEvents and in OnConnection method it subscribes to receive notifications from Inspectors COM (such as OnNewInspector).
Also I tried to debug such scenario and noticed that the inspector window arises earlier than my add-in dll is loaded, so it doesn't have time to subscribe for notification.
Have I missed something to care about? Any ideas how to handle OnNewInspector event if outlook is running with -Embedding param ?



Ken Slovak - [MVP - Outlook]

Sending an email that way uses Simple MAPI. If Outlook is the default mail
handler the Simple MAPI call opens an Outlook item in an Inspector, but an
Inspectors.NewInspector() event is never fired. That's the case with all
versions of Outlook.

In versions later than Outlook 2000 the Inspector is added to the Inspectors
collection even though NewInspector() never fires. In Outlook 2000 or
earlier the Simple MAPI Inspector isn't added to the Inspectors collection.

The Simple MAPI Inspector is always opened as a modal Inspector window.

In order to be able to handle Simple MAPI Inspectors like that you would
need something like a timer event that fires at intervals. In the timer
event handler you would check for an Inspector not already handled that's in
the Inspectors collection.

You do have to do this very carefully with various interlocks and checks in
both the timer handler and in NewInspector() to ensure that you don't end up
handling the same Inspector twice.

A Simple MAPI Inspector always uses the Outlook editor, even if the default
is WordMail (other than in Outlook 2007, where there is no Outlook editor).

Handled correctly these techniques allow you to handle Simple MAPI
Inspectors and to add your UI to them.

Brian Graham

Hi Ken,

I have a related problem with Outlook 2007. I have an VSTO SE addin that
adds a group and a button to the ribbon bar of the email inspector.

When I create the email from Outlook my wrapper code is called via
newinspector all is well and the email sends and closes.

However, if the email is started via the Send To, simple mapi call from
another app my ribbon bar changes appear in the inspectors ribbon (with no
effect because my code is not loaded) and the inspector window window will
not close on send. The user has to close it manually.

I have tried the timer approach to get a wrapper around the inspector and
this works to enable the button to work but it still does not get rid of the
Window on send.

I am marshalling all the com objects I can find and doing the gc.wait for
finalizers that I have seen mentioned elsewhere but to no avail.

The only way I have found that works is to comment out the
protected override object RequestService(Guid serviceGuid)
method so my xml is never loaded.

Any ideas?

My xml is fairly simple:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui"
onLoad="OnLoad" loadImage="GetImage">
<tab idMso="TabNewMailMessage">
<group id="LDGroup"
<toggleButton id="toggleProfile"
screentip="Show / Hide the profile card."
image="Gavel48" />

Thnaks for any help you can give me.

The only thing I can think of at the moment is to overwrite the simple mapi
call in all the other email apps and use another method that does fire the
new inspector event but thats a lot of work.

Brian Graham

Ken Slovak - [MVP - Outlook]

Is this working now? I'm not sure if this is the same problem in your other
thread or a different one.

Brian Graham

Yes, it all looks OK now. It was my stupid mistake. Thanks for the check-in
and thank you for the timer idea to wrap these simple mapi initiated

Do you know if MS will change this in a future version. It seems a bit
incongruous that the inspectors have all the Ribbon bar customisation but do
not fire NewInspector so we can build any custom task panes that the Ribbon
bar customisations need.

Thanks again for all the indirect help you have given me over the last few
months as I have struggled to get my head around Outlook addins. Your answers
to other developers have saved my sanity on more than one occasion. :->




Ken Slovak - [MVP - Outlook]

I don't know if MS will change this in the future to fire NewInspector when
a Simple MAPI Inspector is opened. I suspect it's rather low on their list.
At least now we get the Simple MAPI Inspector added to the Inspectors
collection, in Outlook 2000 and earlier that didn't happen and you had no
way of knowing from within Outlook that a Simple MAPI Inspector had been

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