Inspector.Close() does not work.

S

Sunny

Sorry for re-post, but I haven't receive an answer so far.

Hi, I'm developing an addin for Outlook 2000 with C# / VS.net 2003.

What I try to do is, when a user tries to open an appointment, and if this
appointment belongs to a particular category (mine), I want to display
something mine, and not to open the item.
So, I couldn't find any easy solution, and decided to trap the creation of
every new inspector and to look what item it is trying to open, and if it is
mine, I just display mine form and invoke Item.Close() and
Inspector.Close().
But it doesn't close that inspector, so it always opens over mine form.

Below is code of event handler. It traps the event and works OK, except that
it doesn't close the Inspectoir.

Any ideas / help will be highly appreciated.
Sunny

THE CODE : :)

public static void applicationInspectors_NewInspector(Outlook.Inspector
oInspector)
{
string sUrl = "";
if (oInspector.CurrentItem is Outlook.AppointmentItem)
{
Outlook.AppointmentItem currItem =
(Outlook.AppointmentItem)oInspector.CurrentItem;
if (currItem.Categories.IndexOf(myCategory) >= 0) //we've got it,
get the data :)
sUrl = currItem.UserProperties.Item("URL").Value.ToString();
currItem.Close(Outlook.OlInspectorClose.olDiscard);
System.Runtime.InteropServices.Marshal.ReleaseComObject(currItem);
currItem = null;
oInspector.Close(Outlook.OlInspectorClose.olDiscard);
}

if (oInspector != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oInspector);
oInspector = null;
}
if (sUrl != "")
OpenMyForm(sUrl);
}
 

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