Custom Ribbon causing problems with Link by E-mail

J

Jacob Adams

I am developing an add-n for Outlook 2007 with VSTO 3.0. I have an
OfficeRibbon class that is set to Microsoft.Outlook.Mail.Compose.

It works great except for when a user selects another application (like IE)
and sends something via email (like File->send->link by email). In this
case, the compose window is brought up. After selecting send, either the
window remains open or a second compose window is opened.

If I exclude the ribbon file from my addin project or comment out the
InitializeComponent routine, everything works fine.

Is there something I can do to address this?
 
K

Ken Slovak - [MVP - Outlook]

What you are seeing is a Simple MAPI Inspector called by Send To. That adds
the Inspector to the Inspectors collection but does not fire the
NewInspector event. Are you doing any initializations in NewInspector that
would be missing in this case? Another possibility is if you are normally
handling Inspector.Close or item.Close and due to the lack of
initializations the code isn't being called.

You should make sure that in these cases the initialization, close and
release code you use is actually called. You can check that in the ribbon
callbacks to make sure that the Inspector referenced in the callbacks is
being handled already. If it isn't being handled you can call the init code
you need.

Make sure that all references are released as needed so you aren't causing
leaks or handles that aren't released.

You may also need to handle the item.Send event and at the end of that event
if it's a Simple MAPI Inspector you might need to set up a timer to fire in
a short interval to close and discard the item and Inspector. You can't do
that in Outlook 2007 in either Close event handler or in Send, so a timer
would be necessary.

Also, please do not multipost. Post in one group or put all the groups in
one address line.
 
J

Jacob Adams

Thanks for the info about the simple mapi inspector!

Before, we were using the Ribbon(Visual Designer) item to create the ribbon
button. By changing it to a Ribbon(XML) item, the problem seems to have gone
away in most cases.

However, we also have a send event handler for checking the number of
recipients. Like you mentioned, the NewInspector event is not getting fired,
so adding this handler for simple mapi objects appears to be impossible. As
you mentioned, we don't seem to be able to handle the send button being
clicked. I also don't see a way of getting the inspector before the button
is clicked.

P.S. Sorry about the cross posting thing. I didn't see the option to do this
the first time.
 
K

Ken Slovak - [MVP - Outlook]

You'd have to use some sort of timer that when it fires you check for
unhandled Inspectors to see if there's a Simple MAPI Inspector there not
being handled. Of course you'd need interlocks to make sure you didn't
handle the Inspector in the timer event before NewInspector fires for a
normal Inspector to ensure you aren't handling the same Inspector twice, and
to make sure that if you are in NewInspector you are blocking the timer
event handler. It's very tricky to get right and to not get replication of
Inspector handling and to not somehow hang Outlook while making the
interface as responsive as possible. It took me a long time to get all the
elements working together correctly.
 

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