Home > Net >  VSTO Outlook: Get last email address just entered in the "To", "Bc" or "Cc&
VSTO Outlook: Get last email address just entered in the "To", "Bc" or "Cc&

Time:07-03

I am trying to get the last recipient (email address) just introduced into the "To", "Bc" or "Cc" fields when field loses its focus. How can I achieve this?

For example:

  • if user just types in an email address within "To" field I want to get that.
  • if user just types in an email address within "Bc" field I want to get that.
  • if user just types in an email address within "Cc" field I want to get that.

CodePudding user response:

Use MailItem.PropertyChange event. Whenever any recipient is changed (added/deleted), the event handler fires for all 3 (To/CC/BCC) properties, so your won't know which one changed. You'd need to cache the old value first, and when the event fires, compare it with new value.

PropertyChange ("To")
PropertyChange ("CC")
PropertyChange ("BCC")

CodePudding user response:

You can handle the MailItem.PropertyChange event which is fired when an explicit built-in property (for example, Subject) of the object is changed. The property name is passed to the event so that you can determine which property was changed.

The Recipients property returns a Recipients collection that represents all the recipients for the Outlook item. So, you could get easily get the items for the To, Cc or Bcc fields.

  • Related