Send To ->Mail Receipient hangs with outlook add-in is enabled

R

Ryan2002

I'm developing an outlook 2007 add-in, everything seems to work fine until
I selected a word document from my desktop and right click on windows
explorer, send to and Mail Recipient, the new message windows appears as
normal. Completed the email info and click on the 'Send' button, the new
email windows hangs until I close it manually. Although it seems like the
window hangs however the email is being sent in the background.

In addition, if I composed a new message within Outlook 2007 then it works
fine, the problem only occurs thru Send To -> Mail Recipient. Any info would
be a great help.

Thanks
 
K

Ken Slovak - [MVP - Outlook]

Are you handling NewInspector() in your code?

What happens with your code if an Inspector is in the Inspectors collection
but never fired the NewInspector() event? That's what happens when you open
a Simple MAPI Inspector.

Are you handling Application_ItemSend() perhaps, and trying to work with
that Simple MAPI Inspector without proper initialization of something?

That "ghost" Inspector is usually a symptom of some mishandling of the
Send/Close events. In managed code it can also be a failure to properly
release instance objects for that Inspector and item, perhaps caused by one
of the above conditions?
 
R

Ryan2002

Thanks so much for responding to my questions. Let me give you a little more
info about my problems. Since I was not able to debug the issue, I created a
separate project and try to replicate the problem with similar functionality,
so here's what I've observed.

In my outlook add-in, I added a ribbon component. The ribbon has 1tab/1
group, very simple, no codes behinds except the InitializedComponent.
Anyway, if I set this.RibbonType = "Microsoft.Outlook.Mail.Read", the no
issue but if I set this.RibbonType = "Microsoft.Outlook.Mail.Compose", then
when clicking on the 'Send' button, the window hangs.

I hope the info I provided helps in determining the issues better.

Thanks alot Ken.
 
K

Ken Slovak - [MVP - Outlook]

You didn't answer any of my questions, so I'm just guessing here.

My guess is that you are getting the ribbon on the Simple MAPI Inspectors
and you need to implement ribbon callbacks for getEnabled and getVisible
that test for the Inspector passed to those callbacks and either return
false where the Inspector isn't being handled correctly or that you then
instantiate the handling for that Inspector in those callbacks.
 
R

Ryan2002

Sorry Ken didn't answer your questions and your guess were right. Simple
MAPI Inspector called by Send To does not fire the NewInspector event. I
found other posts that talked about the same problem I am facing. Since we
were not able to handle the 'Send' button clicked, so some just switch from
implementing Ribbon (Visual Designer) to Ribbon (XML) and that fixed their
problems. However, you suggested to handle thru timer, can you please send
me your sample codes that resolved this issue. Thanks. BTW, is it a bug or
function as designed?

Below is Jacob Adams question which is exactly as mine and your suggestions
to him

"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. "


You wrote:

"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. "
 
K

Ken Slovak - [MVP - Outlook]

It's as designed, although to me it's a bug.

Sorry, my code for handling Simple MAPI Inspectors is proprietary so I don't
give it out. You have the information I provide on that, and can take it
from there. Just make sure whatever timer you use is on the main thread and
not a background thread, and allocate plenty of time to get the timer timing
and interlocks working right.
 
R

Ryan2002

Thanks Ken for being honest. However, I have another question for you. With
the Outlook Add_in and Ribbons (visual Designer) , is there a way to detect
when the email being sent from Simple MAPI Inspector versus Outlook app? I
would like to be able to determine if the email is being called from Simple
MAPI inspector, this way, I can prevent the ribbons from initializing.
Thanks.
 
K

Ken Slovak - [MVP - Outlook]

The only way is a negative proof, that there's an Inspector that is in the
Inspectors collection but it didn't fire the NewInspector() event.

With the timer method you can tell from that and you can set a property in
your Inspector wrapper class that tells you the Inspector is a Simple MAPI
Inspector. I've done that for various reasons in some of my addins.

But once you've got all that's needed in place you're also in a position to
handle those Simple MAPI Inspectors just as you'd handle normal Inspectors.
 

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