Fixed font Subject: Re: Inspector.Close event is not fired
Author: Ken Slovak - [MVP - Outlook] Date: 26 Feb 2010
References: 1 2 3
I'm not sure who you're addressing since the rest of the thread has scrolled
off the server and you don't provide any clues or context. You're also not
providing any information about the Outlook version you're working with.

First of all, if you look at the object browser you will see that the
Inspector.Close() event does not have a Cancel argument. The event cannot be
cancelled. The ContactItem.Close() event (and other item types) does have a
Cancel argument, so if you want to cancel closing the item based on certain
conditions you should be handling that event and not Inspector.Close().

For an item.Close() handler you wouldn't use Outlook.ItemsEvents_Event, but
you could use Outlook.ItemEvents_Event. Note that your code uses ItemsEvents
and the following uses ItemEvents with no "s" in Item.

If you were to use that way of handling ContactItem.Close() you would
instantiate it as follows:

// at class level
private Outlook.ItemEvents_Event _itemEvents = null;

// init code

_itemEvents = (Outlook.ItemEvents_Event)m_contact;

// hook up the ContactItem Close event handler

_itemEvents.Close += new Outlook.ItemEvents_CloseEventHandler(OnItem_Close);


Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm

"Md.A.RaheeM" <Md.A.RaheeM@discussions.microsoft.com> wrote in message
news:1045F108-EDB4-4495-A922-69F88AD896A5@microsoft.com...
> Hi Sir..
>
> i tried to use ur code block in C# VS2008...:
> // at class level
> private Outlook.ItemsEvents_Event m_events;
> private Outlook.ContactItem m_contact;
>
> // in init code
> m_events = (Outlook.ItemEvents_Event)m_contact;
> m_events.Close += new
> Outlook.ItemEvents_CloseEventHandler(m_contact_Close);
>
> // event handler
> private void m_contact_Close(ref bool Cancel)
> {
> // whatever
> }
>
>
> but i am getting two errors as below:
> 1) 'Microsoft.Office.Interop.Outlook.ItemsEvents_Event' does not contain a
> definition for 'Close' and no extension method 'Close' accepting a first
> argument of type 'Microsoft.Office.Interop.Outlook.ItemsEvents_Event'
> could
> be found (are you missing a using directive or an assembly reference?)
>
> 2) Cannot implicitly convert type
> 'Microsoft.Office.Interop.Outlook.ItemEvents_Event' to
> 'Microsoft.Office.Interop.Outlook.ItemsEvents_Event'. An explicit
> conversion
> exists (are you missing a cast?)
>
> plz help me on this..... by providing solution on how to disable the
> default close(x) button of Inspector window
> --OR--
> let me know how to catch the Item.close event / Inspector.Close Event...
>
>
> Thanks
>
> Regards
> Md.A.RaheeM