Dealing with multiple mail inspectors (Outlook)

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

Dealing with multiple mail inspectors (Outlook)
 
Patrick Meehan


Guest


Since only one instance of the addin is created when Outlook starts, all mail inspectors share the same command bar object. Since my addin carries some state with it, I would prefer to have a unique command bar for each mail inspector that can be configured independently of the others. Is there any easy way to do this?

If not:

How can I force all of the inspectors to update and show the current state of the addin? For example, if I dynamically change a command bar button caption to reflect a setting chosen by the user, how can I make sure that other open inspectors update to reflect this change?

Any help would be appreciated!

Thanks,
Patrick
Posted 11 Aug, 2005 18:59:24 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Patrick.

To update the command bar/add-in you can use the InspectorActivate event handler of the ADXOutlookAppEvents component. This event handler provides you the "inspector" parameter that can be used for getting of the active inspector. Based on the state of the active inspector you can change the properties of the command bar and controls (e.g. Caption, Enabled, Visible, Image and so on).
Posted 13 Aug, 2005 18:28:55 Top
Patrick Meehan


Guest


OK, thanks Sergey. I will work with that some.
Posted 15 Aug, 2005 13:37:49 Top
Patrick Meehan


Guest


OK, if I understand this correctly, the InspectorActivate event will alert me when an open inspector recieves focus. But this isn't quite enough. Consider these two approaches:

1) I want to update the add-in with whatever settings the user last selected for that particular mail item. So... I need to store some extra data (like a date, for example) per mail item to remember the user's settings. When the inspector is re-activated I need to find out which mail item it is an inspector for and refresh the add-in with the correct value associated with that mail item. If there were a way to uniquely identify each mail item (say with an ID) then I could keep a table that maps mail items onto their user data. But I haven't found anything in the MailItem that could uniquely identify it, other that the fields of the mail itself, which will change and could also be redundant. Thoughts?

2) If there is no way to reliably identify mail items, I would instead want to update *all* open inspectors each time the data changes. In this case, I am thinking about only one user data for *all* inspectors (as opposed to a unique user data for each inspector). It looks like the InspectorActivate is fired when an inspector gains focus, but how can I force this event to fire for all open inspectors so that they may all be updated at once? It is cheesy to let the user change the date and then only update the other inspectors when focus changes; there may still be inspectors open on the screen with the wrong date.

So... can you think of any reliable way to either (1) uniquely identify a mail item OR (2) force an update across *all* open inspectors?

As always, your help is appreciated!

Thanks,
Patrick
Posted 15 Aug, 2005 14:20:51 Top
Guest


Guest


Looks like I can do:

Microsoft.Office.Core.CommandBarButton officeButton = this.adxCommandBarButton.ControlObj as Microsoft.Office.Core.CommandBarButton;
...
UserData userData = myUserDataTable [ officeButton.InstanceId ];

A start but still not ideal... the add-in will forget the user's settings for a given mail item if they close and re-open an inspector. I can identify a unique inspector, but still not a unique mail item.
Posted 15 Aug, 2005 14:35:17 Top
Patrick Meehan


Guest


Oops, sorry, that last post was from me...
Posted 15 Aug, 2005 14:35:49 Top
Sergey Grischenko


Add-in Express team


Posts: 7233
Joined: 2004-07-05
Hi Patrick.

If there were a way to uniquely identify each mail item (say with an ID) then I could keep a table that maps mail items onto their user data.

You can use the Outlook._MailItem.EntryID property to uniquely identify each mail item.

It looks like the InspectorActivate is fired when an inspector gains focus, but how can I force this event to fire for all open inspectors so that they may all be updated at once?

Try to use the Outlook._Application.Inspectors property of Outlook application object to access all open inspectors.
Posted 16 Aug, 2005 08:18:03 Top