Hooking up events and Form from Mail compose in explorer

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

Hooking up events and Form from Mail compose in explorer
 
Bert Sinnema


Guest


Hi,

I have created a nice add-in that adds a form to the Inspector of a MailItem when in Compose mode. Its hooked up to some events in the email and it works great. But, when I do a Reply, Reply All or Forward from the Explorer in Outlook 2013 it stays in Explorer mode and the Form that is hooked up to the Inspector normally is not shown.

In the Forms manager I also added this to the explorer. And two things are not working.

1. The form is always visible, I would like to have it only visible when in Compose mode, how do i context this?
2. The events are not hooked up to the current item in Compose mode, how do i do this?

I really don't want to force pop-out.

Cheers,
Bert
Posted 19 May, 2015 08:03:13 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Bert,

To handle the visibility of the form instance, you set ADXOlForm.Visible=false/true in the ADXOlForm.ADXFormBeforeShow event.

To connect to events of an item selected in the Explorer window, you need to handle the ExplorerSelectionChange event of the Outlook Events component. In the event handler you connect an Outlook Item (not Items!) Events class (see the Add New Item dialog of your add-in project) to the selected item.

To connect to events of an item opened in an inspector window, you need to handle the InspectorActivate event of the Outlook Events component. In the event handler you connect an Outlook Item (not Items!) Events class to the item opened in that inspector.

There are two strategies:
- you connect to a single item at a time
- you connect to several items at a time

In the first case, connecting to an events of an item also means disconnecting from events of the previously connected item. Imagine switching between an Outlook Explorer and Inspector windows.

In the second case you can use a dictionary to keep all instances of the Outlook Item Events class opened in inspector windows and selected in explorer windows. The key of the dictionary would be the handle of these windows - use ADXAddinModule.GetOutlookwindowHandle() and/or ADXOlForm.CurrentOutlookwindowHandle.

Whatever approach you use, you need to release all items connected when the add-in unloads.


Andrei Smolin
Add-in Express Team Leader
Posted 19 May, 2015 08:44:33 Top