Reputation: 166
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
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
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