How to stop closing Inspector in_InspectorClose in adxOutlookAppEvents

Add-in Express™ Support Service
That's what is more important than anything else

How to stop closing Inspector in_InspectorClose in adxOutlookAppEvents
 
Sandun Dav Frank




Posts: 13
Joined: 2016-03-30
I am checking every _InspectorClose event to check All required fields are filled in the inspector.
If required fields not filled I want to show message box and stay the inspector without closing.

private void adxAppEvents_InspectorClose(object sender, object inspector, string folderName)
{

try
{
Outlook.Inspector ins = OutlookApp.ActiveInspector();
Outlook.MailItem mail = null;
Outlook.AppointmentItem appointment = null;
Outlook.ContactItem contact = null;
if (ins != null)
{
item = ins.CurrentItem;
if (item != null)
{
if (item is Outlook.MailItem)
{
mail = item as Outlook.MailItem;
}
else if (item is Outlook.AppointmentItem)
{
appointment = item as Outlook.AppointmentItem;
}
else if (item is Outlook.ContactItem)
{
contact = item as Outlook.ContactItem;
}

if (contact != null)
{
RequiredFields requiredObj = new RequiredFields();
if (!requiredObj.RequiredFieldsFilled())
{
//Show Messagebox

//Inspector not close
}
}
}
}
}
}
catch (Exception ex)
{
Debug.DebugMessage(2, "Error in adxAppEvents_InspectorClose " + ex.Message);
}
finally
{
if(item != null)Marshal.ReleaseComObject(item);
}
}[CODE]
Posted 20 Dec, 2016 04:40:58 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hello Sandun,

You can't cancel the InspectorClose event; see https://msdn.microsoft.com/en-us/library/office/ff865374(v=office.15).aspx. You could try to use the MailItem.CustomPropertyChange and/or MailItem.PropertyChange event to identify the changes, and cancel the MailItem.Write event to prevent the inspector from closing.

I would recommend that you install our free the Outlook Events Logger. You download it at https://www.add-in-express.com/creating-addins-blog/2010/07/01/outlook-events-tool/. Install the add-in, copy the source code to a location of your choice, uninstall add-in, build the project and register it. The add-in will show you what events occur in this or that scenario.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Dec, 2016 05:24:30 Top
Sandun Dav Frank




Posts: 13
Joined: 2016-03-30
HI Andrei ,
Thanks for the quick reply. So you mean is there no any method to exit the _InspectorClose event. And inspector not close if the condition passed.

Is it possible we open again that inspector inside the
if (!requiredObj.RequiredFieldsFilled()) .
And it is not any harm to performance of the plugin?

(I just need to if messageBox popup not closing the inspector)
Posted 20 Dec, 2016 07:34:40 Top
Andrei Smolin


Add-in Express team


Posts: 14094
Joined: 2006-05-11
Hello Sandun,

There's no way to cancel the InspectorClose event; that is, you can't use this event to prevent the inspector form closing.

Sandun Dav Frank writes:
Is it possible we open again that inspector


Note that an inspector contains a visual representation of an item (e.g. MailItem, ContactItem, etc.) To reopen an inspector means to call MailItem.Display.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Dec, 2016 08:03:10 Top