none
Call a function when a mail item is clicked in Outlook RRS feed

  • Question

  • Hello.  I am trying to call a function that adds a menu when a mail item is clicked.  I tried http://msdn.microsoft.com/en-us/library/bb296010.aspx .  Does anyone have documentation on this?  Thank you.
    Wednesday, January 27, 2010 4:52 AM

Answers

  • Hello Mark,

    I think you are looking for this MSDN article which introduce how to add a menu: How to: Add Custom Icons to Toolbar and Menu Items. As far as I know, Outlook Object Model does not expose an event like click event on a mail item. However, I think you could SelectionChange event [See: Explorer.SelectionChange Event]. In this event handler, use Count property and index of this.Application.ActiveExplorer().Selection to check if item selected currently is a mail item. Code like this,

                Outlook.Selection sel = this.Application.ActiveExplorer().Selection;
                if (sel.Count == 1 )
                {
                    Outlook.MailItem mi = sel[1] as Outlook.MailItem;
                }

    If you have any concern for this post, please feel free to follow up.

    Best regards,
    Bessie

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bessie Zhao Tuesday, February 2, 2010 7:14 AM
    Thursday, January 28, 2010 5:15 AM

All replies

  • Hello Mark,

    I think you are looking for this MSDN article which introduce how to add a menu: How to: Add Custom Icons to Toolbar and Menu Items. As far as I know, Outlook Object Model does not expose an event like click event on a mail item. However, I think you could SelectionChange event [See: Explorer.SelectionChange Event]. In this event handler, use Count property and index of this.Application.ActiveExplorer().Selection to check if item selected currently is a mail item. Code like this,

                Outlook.Selection sel = this.Application.ActiveExplorer().Selection;
                if (sel.Count == 1 )
                {
                    Outlook.MailItem mi = sel[1] as Outlook.MailItem;
                }

    If you have any concern for this post, please feel free to follow up.

    Best regards,
    Bessie

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bessie Zhao Tuesday, February 2, 2010 7:14 AM
    Thursday, January 28, 2010 5:15 AM
  • in outlook I am trying to , fireup a sub when I click on an email.

    Which event gets executed?

    Thursday, February 6, 2014 2:41 PM
  • Hello Cemal,

    First of all, I'd recommend creating new forum threads for separate questions instead of blowing up old forum threads that were marked as answered.

    It looks like you are interested in the SelectionChange event of the Explorer class from the Outlook object model. The event is fired when the user selects a different or additional  Microsoft Outlook item programmatically or by interacting with the user interface. Here is what MSDN states for the event:

    This event also occurs when the user (either programmatically or via the user interface) clicks or switches to a different folder that contains items, because Outlook automatically selects the first item in that folder. However, this event does not occur if the folder is a file-system folder or if any folder with a current Web view is displayed. This event is not available in Microsoft Visual Basic Scripting Edition (VBScript).

    • Proposed as answer by Cemal Saturday, February 8, 2014 3:00 PM
    Friday, February 7, 2014 5:58 PM