Ben
Ben

Reputation: 166

Detect if outlook inspector window has closed

For an addin for Outlook 2016 I have to detect if an inspector window (email window) has closed.

I've found a guid on the microsoft website but I can't seem to get it working. https://msdn.microsoft.com/en-us/library/office/ff184620.aspx
I Can't seem to find a way to add a method to the close event

((Outlook.InspectorEvents_Event)inspector).Close +=
        new Outlook.InspectorEvents_CloseEventHandler(
        OutlookInspectorWindow_Close);

Has anyone found a way to get it working? I don't seem to have an InspectorEvents_Events object.

Thanks in advance




Edit

My close isn't an event, it's a method, as mentioned here Registering to the Outlook appointment item 'closed' event using VSTO
You have to force a cast using:

((InspectorEvents_10_Event)inspector).Close += Closed;

I didn't get it to work because my compiler didn't suggest InspectorEvents_Event or InspectorEvents_10_Event

Upvotes: 1

Views: 2018

Answers (1)

Eugene Astafiev
Eugene Astafiev

Reputation: 49397

You need to cast the inspector object to the InspectorEvents_10_Event interface:

        var inspector = Inspector as InspectorEvents_10_Event;
        if (inspector != null)
        {
            inspector.Close += OnInspectorClose;
        }

Upvotes: 2

Related Questions