none
How to get the TO Field email address for send button click event in MS Outlook using c++ RRS feed

  • Question

  •  I am working on outlook add-in project using Visual studio 2008 for MS Outlook 2013 in C++. I am using COM interfaces.

    When we click New Mail Message, a new window will appear from which we can send a new mail. I want to get TO field email address and Subject of the email when clicking on send button.

    I have used:

    void __stdcall CConnect::OnSend() 
    method for click on send button.

    In this function I have used _MailItem interface. For getting To Field email address used get_To() method of _MailItem interface. But I got NULL string from this function.

    How to get the exact email address?
    Tuesday, June 23, 2015 11:30 AM

Answers

  • Hello Deepali,

    It looks like you are trying to get the To recipient email address in the Send event handler. I'd suggest using the Recipients property of the MailItem class to get the required information instead. Though the To property is a valid way - a semicolon-delimited string list of display names for the To recipients for the Outlook item. The Outlook object model doesn't reflect changes made through the UI immediately, sometimes you need to call the Save method to apply changes.

    You may consider using the ItemSend event of the Application class instead. It is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Sendbutton) or when the Send method for an Outlook item, such as MailItem, is used in a program.


    Tuesday, June 23, 2015 8:54 AM

All replies


  • I am working on outlook add-in project using Visual studio 2008 for MS Outlook 2013 in C++. I am using COM interfaces.

    When we click New Mail Message, a new window will appear from which we can send a new mail. I want to get TO field email address and Subject of the email when clicking on send button.

    I have used:

    void __stdcall CConnect::OnSend() 
    method for click on send button.

    In this function I have used _MailItem interface. For getting To Field email address used get_To() method of _MailItem interface. But I got NULL string from this function.

    How to get the exact email address?

    Monday, June 22, 2015 10:03 AM

  • I am working on outlook add-in project using Visual studio 2008 for MS Outlook 2013 in C++. I am using COM interfaces.

    Development related questions should be posted in the following forum where you'll get a much quicker and more accurate response

    Outlook for Developers
    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev


    Karl Timmermans [Outlook MVP] "Outlook Contact Import/Export/Data Mgmt" http://www.contactgenie.com

    Monday, June 22, 2015 11:29 AM
  • Hello Deepali,

    It looks like you are trying to get the To recipient email address in the Send event handler. I'd suggest using the Recipients property of the MailItem class to get the required information instead. Though the To property is a valid way - a semicolon-delimited string list of display names for the To recipients for the Outlook item. The Outlook object model doesn't reflect changes made through the UI immediately, sometimes you need to call the Save method to apply changes.

    You may consider using the ItemSend event of the Application class instead. It is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Sendbutton) or when the Send method for an Outlook item, such as MailItem, is used in a program.


    Tuesday, June 23, 2015 8:54 AM
  • Hello Deepali,

    Please don't create duplicates on the forum, see How to get the TO Field email address for send button click event in MS Outlook using c++

    Tuesday, June 23, 2015 11:41 AM