none
Inspector Wrapper for Outlook 2013 RRS feed

  • Question

  • Hi Guys,

    I have developed an Inspector Wrapper for Outlook 2010, its works perfectly.

    Now, I would like to run it on Outlook 2013, and it does not work, does someone have any idea or information on how to implement it for Outlook 2013?

    Thanks,

    Itay

    Monday, February 24, 2014 4:31 PM

Answers

  • Hello Itay,

    As far as I understand the wrapper is based on the inspector window. But the people section in Outlook doesn't display inspector windows.

    Instead, you need to handle the ItemChange event of the Items class. Also the Explorer class provides the SelectionChange event which is fired when the selected item[s] is changed in the windows (another item[s] is selected). In the event handler you can subscribe to the Write event.


    • Edited by Eugene Astafiev Wednesday, February 26, 2014 11:22 AM
    • Marked as answer by Itay Assraf Thursday, February 27, 2014 4:23 PM
    Wednesday, February 26, 2014 11:20 AM
  • People view has a number of problems.

    I haven't checked to see if this bug is fixed recently, but if People view is on and you have an adjoining Form Region and an item with that Form Region is selected when you exit Outlook, Outlook will crash. The developers in that case are attempting to use a null pointer for something.

    I've had to disable People view or automatically change to a different view to allow some code to run correctly.

    For Write() you can use Items.ItemChange() as Eugene recommended. That however would occur after any Write() event occurred.

    You might want to look into the Application.ItemLoad() event instead.

    In that event only Class and MessageClass are valid (it's a weak object reference at that point in time), but those can be used to see if it's a contact item, if a Contacts folder is ActiveExplorer().CurrentFolder, and if ActiveExplorer().CurrentView is a People view.

    If those cases are all true you can then take the Item reference from ItemLoad() and add your Write() handler for the item.

    If more than one item needs to be handled you can extend the wrapper concept  to your new PeopleViewItem handler.


    Ken Slovak MVP - Outlook

    • Marked as answer by Itay Assraf Thursday, February 27, 2014 4:22 PM
    Wednesday, February 26, 2014 3:27 PM
    Moderator

All replies

  • Hello Itay,

    Do you get any error or exception? What do you mean saying "it does not work"? Could you please be more specific?

    Monday, February 24, 2014 4:38 PM
  • Hi Eugene,

    Actually nothing happens, the events that the Inspector Wrapper capture from Outlook 2010(like Contact window closed), are not captured in Outlook 2013, and no exception is raised.

    Thanks,

    Itay

    Tuesday, February 25, 2014 7:14 AM
  • What code do you use for the Inspector wrapper?
    Tuesday, February 25, 2014 7:43 AM
  • It is according to http://msdn.microsoft.com/en-us/library/ff973716.aspx

    Tuesday, February 25, 2014 8:52 AM
  • Did you try to run the empty sample code without any modifications?

    The fact is that Outlook 2013 didn't introduce anything new. All stuff should work as expected.

    Tuesday, February 25, 2014 12:09 PM
  • That would actually depend on whether Outlook 2013 is disabling the addin for any one of the performance reasons. The wrapper may not be working, although Helmut's code should work perfectly, but is the addin itself running in 20013 or was it disabled?

    See http://msdn.microsoft.com/en-us/library/office/jj228679.aspx#ol15WhatsNew_AddinDisabling for more information on this.


    Ken Slovak MVP - Outlook

    Tuesday, February 25, 2014 3:12 PM
    Moderator
  • I have downloaded the empty sample code(Helmut's code), and opened it with VS2013, and tested it with Outlook 2013, generally it worked fine, however when I edit and save a contact, it does not work, the Item_Write event does not get triggered.

    Does anyone have a suggestion?  

    Tuesday, February 25, 2014 4:09 PM
  • Does it work with other types of items aside from contacts?

    Show a brief snippet of the code you're using to set up the Write() handler for the wrapper class.


    Ken Slovak MVP - Outlook

    Tuesday, February 25, 2014 4:41 PM
    Moderator
  • It does work with other types (I have checked mail, task and appointment), for contact it works when you create a new one, but for update:

    • When you are in the ‘People’ view – does not work.
    • Any other view (‘Business Card’, ’Card’, etc...) – it works.

     internal class ContactItemWrapper : InspectorWrapper {
    
            /// <summary>
            /// .ctor
            /// </summary>
            /// <param name="inspector">The Outlook Inspector instance that should be handled</param>
            public ContactItemWrapper(Outlook.Inspector inspector)
                : base(inspector) {
            }
    
            /// <summary>
            /// The Object instance behind the Inspector (CurrentItem)
            /// </summary>
            public Outlook.ContactItem Item { get; private set; }
    
            /// <summary>
            /// Method is called when the Wrapper has been initialized
            /// </summary>
            protected override void Initialize() {
                // Get the Item of the current Inspector
                Item = (Outlook.ContactItem)Inspector.CurrentItem;
    
                // Register for the Item events
                Item.Open += new Outlook.ItemEvents_10_OpenEventHandler(Item_Open);
                Item.Write += new Outlook.ItemEvents_10_WriteEventHandler(Item_Write);
    
                // Set the initial size of the Inspector
                Inspector.Width = 800;
                Inspector.Height = 600; 
            }
    
            /// <summary>
            /// This Method is called when the Item is saved.
            /// </summary>
            /// <param name="Cancel">When set to true, the save operation is cancelled</param>
            void Item_Write(ref bool Cancel) {
                //TODO: Implement something 
            }



    • Edited by Itay Assraf Wednesday, February 26, 2014 9:08 AM
    Wednesday, February 26, 2014 8:33 AM
  • Hello Itay,

    As far as I understand the wrapper is based on the inspector window. But the people section in Outlook doesn't display inspector windows.

    Instead, you need to handle the ItemChange event of the Items class. Also the Explorer class provides the SelectionChange event which is fired when the selected item[s] is changed in the windows (another item[s] is selected). In the event handler you can subscribe to the Write event.


    • Edited by Eugene Astafiev Wednesday, February 26, 2014 11:22 AM
    • Marked as answer by Itay Assraf Thursday, February 27, 2014 4:23 PM
    Wednesday, February 26, 2014 11:20 AM
  • People view has a number of problems.

    I haven't checked to see if this bug is fixed recently, but if People view is on and you have an adjoining Form Region and an item with that Form Region is selected when you exit Outlook, Outlook will crash. The developers in that case are attempting to use a null pointer for something.

    I've had to disable People view or automatically change to a different view to allow some code to run correctly.

    For Write() you can use Items.ItemChange() as Eugene recommended. That however would occur after any Write() event occurred.

    You might want to look into the Application.ItemLoad() event instead.

    In that event only Class and MessageClass are valid (it's a weak object reference at that point in time), but those can be used to see if it's a contact item, if a Contacts folder is ActiveExplorer().CurrentFolder, and if ActiveExplorer().CurrentView is a People view.

    If those cases are all true you can then take the Item reference from ItemLoad() and add your Write() handler for the item.

    If more than one item needs to be handled you can extend the wrapper concept  to your new PeopleViewItem handler.


    Ken Slovak MVP - Outlook

    • Marked as answer by Itay Assraf Thursday, February 27, 2014 4:22 PM
    Wednesday, February 26, 2014 3:27 PM
    Moderator
  • Thank you Eugene and Ken for all your advice, it was very helpful.
    Cheers, Itay
    Thursday, February 27, 2014 4:24 PM