delete e-mail in inspector problem

M

Mark Smith

My addin places a tool bar with a button on each inspector window. As per
previous advice I am using the Item Close event rather than the Inspector
Close event to delete my toolbar wrapper (ToolBar).

If the user uses the previous and next buttons, the Item close event fires
and the ToolBar attached to the inspector gets deleted. Then a New
Inspector event fires and a new ToolBar item is created and attached. On
the other hand, If the user deletes the item, the Item Close event fires,
but no New Inspector event fires. Thus the tool bar gets orphaned and no
longer functions.

So I tried to use the Inspector Close event instead of the Item Close event.
This allows the button to continue functioning after the user deletes an
item. Unfortunately this leaves extra ToolBars around that aren't needed.
In and of itself, this is not a big deal. The problem is that if the user
has used the previous or next buttons or deleted items, when the button is
clicked, the button handler fires for each ToolBar, resulting in the same
operation occuring on that item many times.

I have considered doing something with the tag name to make sure that a
pressing a given button only results in one action, but this seems like a
less than optimal solution. Other than that I can't think of anything. If
there is a better way, I would love to hear it. Any ideas?

Thank you,
Mark Smith
 
K

Ken Slovak - [MVP - Outlook]

Any Inspector or Explorer button should have a unique Tag property. That
prevents what you are describing.

Next and Previous are problems. In fact in certain versions of Outlook you
don't even get a Close event on the Item when they are used. I always
backstop using both Inspector and Item Close since other things may also
change the order in which they fire or prevent one or the other from firing.
Such things as whether or not WordMail is being used and whether or not Send
is pressed can affect that.
 
M

Mark Smith

The main problem I am getting is that when the user deletes the item I get a
close item event but no new inspector event. If I use the close item event
rather than the inspector event, I have no way of properly cleaning up
resources while keeping the toolbar working.

Mark
 
M

Mark Smith

Now that I think about it, I'm not sure how having a unique tag name will
help. I already do have a unique tag name created for each button. But
because of how the inspectors work, I have one button which may be attached
to several inspectors (because of the use of the previous and next buttons).
Thus when the one button is pressed, all inspectors' event sinks fire. And
because there is only one actual button, there is only one tag name to test
against, not one for each inspector. Perhaps I need to set up my buttons
differently? The way I am currently doing it is that when a new inspector
event occurs I search for the toolbar and button, and if they already exist,
I attach to the existing one. If it doesn't, then I create it. This worked
fine as long as I was using the item close event, but if I switch to the
inspector close event I get this problem.

Mark
 
K

Ken Slovak - [MVP - Outlook]

The way to handle multiple Inspectors is by using a collection of them
backed with a wrapper class that handles the events in each Inspector. With
that methodology and use of unique tags for the buttons in each Inspector
you avoid the problem of a button click firing in more than one instance of
a button.

See http://www.slovaktech.com/code_samples.htm#InspectorWrapper for an
example of an Inspector wrapper done in VB 6. A C# example can be found at
www.outlookcode.com.
 

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