not getting inspectors close event on reply forms

R

robert dugal

I have an exchange client extension in which I'm using the Outlook
Object Model to track creation and closing of Inspectors so that I can
add a button to the forms in Outlook 2000.

I open a message, reply to it, and send the reply. But I don't ever
get the close event for the reply inspector and this results in some
OOM objects not getting released and then Outlook won't completely
unload from memory. To debug this problem I disabled every piece of
code in my addin except stuff to track the inspectors and log the
events.

When the read form opens I see:
- Install() with context = EECONTEXT_READNOTEMESSAGE
- OnRead()
- OnReadComplete()
- new inspector event
- OnOpen()
- OnOpenComplete()
- inspector gets activated (dispIdMember=0xf001)
- OnSelectionChange()


When I hit the reply button I see:
- Install() with context = EECONTEXT_SENDNOTEMESSAGE
- new inspector event
- OnOpen()
- OnOpenComplete()
- the original msg's inspector gets deactivated (dispIdMember=0xf006)
- the reply's inspector gets activated (dispIdMember=0xf001)

When I hit send I see:
- OnSubmit()
- OnWrite()
- OnWriteComplete()
- OnClose()
- OnCloseComplete()
- reply's inspector gets deactivated (dispIdMember=0xf006)
- the original msg's inspector gets activated (dispIdMember=0xf001)

When I close the original message I see:
- OnClose()
- OnCloseComplete()
- OnWrite()
- OnWriteComplete()
- original msg's inspector gets deactivated (dispIdMember=0xf006)
- original msg's inspector gets closed (dispIdMember=0xf008)


But I don't ever see the reply form's Inspector get closed.
And if instead of hitting Send on the reply I close the reply then
I do see the inspector getting closed.

Anyone have any ideas why this is happening?
 
D

Dmitry Streblechenko

I can reproduce this - looks like an Outlook bug to me. You can try to track
Inspector.CurrentItem.Send event instead.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
K

Ken Slovak - [MVP - Outlook]

I usually instantiate a MailItem declared WithEvents for situations
like that and then I trap the MailItem.Send or .Close events.
 
R

robert dugal

I'm not sure what you mean Dmitry. All I'm really trying to accomplish
is add a button to the standard toolbar of all forms. I can add the
button by tracking the creation of new Inspectors but I've discovered
that due to 2 problems/features in Outlook 2000 I am sometimes unable
to unload Outlook:
(1) I don't always get a Close event for some Inspectors
(2) The same Inspector is sometimes reused

I've implemented a workaround this morning which is working so far. I
create a collection for all the Inspectors I am watching. As new
Inspectors are created/destroyed I add/remove them from this
collection. If the same Inspector is already in the collection I
remove & unadvise the existing one. I still end up with some orphaned
Inspectors in this collection because Outlook never sends a Close
event for them. When my client extension is about to be unloaded I
unadvise these orphaned Inspectors and Outlook can now unload. One
problem with this fix is that if Outlook is left open for long periods
of time the set of orphaned Inspectors could continue to grow. I might
be able to determine when an Inspector has become orphaned during the
Inspector Activate & Inactivate events by checking to see which
Inspectors in my collection are not in Application->Inspectors. I'll
have to do some testing to see if this works.
 
D

Dmitry Streblechenko

I mean that you can just as easily use Item.Send event to do the same
cleanup you do when you get Inspector.Close - just use MailItem.GetInspector
method.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 

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