Get the active Inspector in ProcessAttachmentAdd

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

Get the active Inspector in ProcessAttachmentAdd
I want to know in which inspector my ProcessAttachmentAdd is fied from 
Bert Sinnema


Guest


Hi All,

I have wrote a nice little wrapper that holds states and other information for my add-in per Inspector. This way i can have my add-in function independently between Inspectors. I store the wrappers in a Dictionary in the AddInModule


public Dictionary<Outlook.Inspector, InspectorWrapper> = new Dictionary<Outlook.Inspector, InspectorWrapper>();


Whenever i hit a button or do a check e.g. onPropertyChanging I get the wrapper from the dictionary to see whats going on.


            // Get the inspector
            Outlook.Inspector inspector = e.Context as Outlook.Inspector;
            if (inspector == null) return;

            // Get the wrapper
            InspectorWrapper wrapper = InspectorWrappers[inspector];
            if (wrapper == null) return;

            switch (e.PropertyType)
            {
                case ADXRibbonControlPropertyType.Pressed:
                    if (wrapper.SystemArmed)
                    {
                        e.Value = true;
                    }
                    else
                    {
                        e.Value = false;
                    }
                    break;
            }


Works like a charm! Now, I want to listen to Adding attachments. I did as the documentation described. I added an OutlookItemEvent class and i hooked it up using adxOutlookAppEvents_InspectorActivate. And obviously this event gets fired every time I add an attachment to the MailItem. But I want to do some stuff in my InspectorWrapper cause this holds the logic for my Add-in and i can't seem to find a way to identify the Inspector so I can get my InspectorWrapper. So the question is:



How do i get the Inspector where the ProcessAttachmentAdd is fired from?
Posted 21 Apr, 2015 07:49:57 Top
Andrei Smolin


Add-in Express team


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

See MailItem.GetInspector. In your case, you get the item by casting ADXOutlookItemEvents.ItemObj to e.g. Outlook.MailItem.


Andrei Smolin
Add-in Express Team Leader
Posted 22 Apr, 2015 04:55:00 Top
Bert Sinnema


Guest


Thanks! this works perfectly
Posted 22 Apr, 2015 07:33:48 Top
Andrei Smolin


Add-in Express team


Posts: 18821
Joined: 2006-05-11
Welcome!


Andrei Smolin
Add-in Express Team Leader
Posted 22 Apr, 2015 07:43:31 Top