none
How to capture quick click categories and right clicks in Outlook 2007 RRS feed

  • Question

  • Hi -

    I have been searching for several months for a solution to my problem. Essentially what I have is an add-in for Outlook 2007 that tracks changes for a customer service department and the user that made them. We have multiple reps working in several shared mailboxes. I've got everything working pretty smoothly by using a combination of the explorer.selectionChange and the mailitem.propertychange events.

    However, the issue I have is when a user right clicks on the category column in the explorer to bring up the context menu and selects a category (same for tasks). Also when they use the quick click feature. I can't find an event for either one of these when the mailitem that is being changed isn't the currently selected one (since the selection doesn't change by a right click). A couple of things I've tried are:

    application.itemcontextmenudisplay event - This only works for the context menu of the mailitem but it doesn't fire when the context menu for the categories column is brought up

    Wrapping everything in folder.items to a class that contains a propertychange event - I've tried several methods using this with no real success, mainly because I need to monitor any changes that could happen to ALL items in a particular folder. Since exchange has a 150 mailitem limit at one time this will not work. This method works best by using the items in the explorer.selection but since the selection doesn't change for a right click its a moot point. 

    Used XML in Outlook 2010 - this showed the most promise but for some reason the onAction parameter doesn't work for the Categories gallery (if I'm wrong on this please let me know!!). I even considered rebuilding the Categories context menu by making the default menu invisible and writing a script that creates my own gallery. I got the closest with this but the imageMso's for the Category colors are not available for some reason (Again please correct me if I'm wrong).

    Ideally, I'd like a solution that would work for both 2007 and 2010 because most representatives still use Outlook 2007 and we haven't fully upgraded everyone. However, I'm willing to consider requiring the floor to upgrade to 2010 if necessary.

    Please help!!

    Thursday, January 16, 2014 3:35 AM

All replies

  • Try Items.ItemChange event on that folder.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Thursday, January 16, 2014 5:03 AM
  • Hi dinesh21,

    The following code works like a charm on my PC with Outlook 2013 installed:

    // code for subscribing to the ItemChange event
    Outlook.NameSpace ns = OutlookApp.GetNamespace("MAPI");
    Outlook.Folder folder = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks) as Outlook.Folder;
    Outlook.Items items = folder.Items;
    items.ItemChange += items_ItemChange;
    
    // event handler
    void items_ItemChange(object Item)
    {
       Outlook.TaskItem task = Item as Outlook.TaskItem;
       if (task != null)
       {
           MessageBox.Show(task.Subject);
       }
    }
    The ItemChange event of the Items class is exactly what you are looking for.
    Thursday, January 16, 2014 2:33 PM
  • Hi - Thanks for the reply. The issue I have with Items.itemchange is 1) I am tracking multiple property changes and it won't tell you which specific property changed and 2) I have the add-in running on all client machines so that I know which user made a specific change (the add-in updates a SQL database). Items.itemchange will fire on all the machines if the code is running simultaneously and not just on the machine that made the change.


    Thursday, January 23, 2014 2:32 PM
  • Hi dinesh21,

    You are right, the ItemsChange event doesn't provide any info - just informs that something has been changed.

    The Explorer class provides the Selection property which returns a Selection object that contains the item or items that are selected in the explorer window. So, you can subscribe to PropertyChange or CustomPropertyChange events of currently selected items (not all items simultaneously). Each time the selection is changed the SelectionChange event is fired. So, you can unsubscribe and release previously selected items and then subscribe to the newly selected items. The event occurs when the user selects a different or additional Microsoft Outlook item programmatically or by interacting with the user interface. Thus, you may track what property is changed.

    Thursday, January 23, 2014 4:50 PM
  • Hello -

    I got distracted with some other projects and now have come back to finishing this up. Eugene - thanks for the response. I do use the SelectionChange event which works fine for all instances except when a user clicks on the "task" column of a mail item that is not currently selected and thereby invoking the quickclick. The issue is the quick click on the new mail item is applied before the selectionchange event fires. Since that happens I do not have an opportunity to capture the PropertyChange/CustomPropertyChange events. The same issue happens with Categories but I can atleast set quick click to nothing with categories. There doesn't appear to be a way to deactivate quick click for task flags. Does anyone know of a work around??

    Thanks

    Dinesh...

    Thursday, May 15, 2014 7:18 PM
  • The last resort is to try to handle the ItemChange event of the Items class or the Write event of Outlook items.

    The Outlook object model doesn't provide any other events for this.

    Thursday, May 22, 2014 7:45 AM
  • I found a workaround using some comparison of the LastModificationDate on an email item and the selectionchange event. Essentially if the LastModificationDate and the selectionchange event firing time are the same and a propertychange event is not fired then I initiate a check to see if the flag is set to complete. Since I can capture every other event this will work for the time being. Its not the best but it performs well.

    Thanks for your help!

    Wednesday, July 16, 2014 2:11 PM
  • Good news! Good luck with your project.
    Wednesday, July 16, 2014 2:15 PM