Get email address from MailItem.To?

  • Thread starter Thread starter Mark B
  • Start date Start date
M

Mark B

VSTO OL2007 C#

When I am sending an email, how do I extract the email address component
from the TO field?

MailItem.Recipients field doesn't have any objects in the list before
Outlook sends an item. MailItem.To just has address book names and not email
addresses.
 
Trap the item.Send() event and in that event save the item then read the
recipient properties you want.
 
Please excuse any newbie ignorance on this but I put a breakpoint after the
following code to see what mail.Recipients would expose for me in the
immediate window:

Outlook.MailItem mail1 = Item as Outlook.MailItem;
mail1.Save();

I could get mail1.Recipients.Count to return me 1. I thought
mail1.Recipients(1).emailaddress or similar would return me the raw email
address of the first recipient but I couldn't see that type of thing.

What code would I need to return me the email address?
 
"Error 7 'Microsoft.Office.Interop.Outlook.Recipients' does not contain a
definition for 'Item' and no extension method 'Item' accepting a first
argument of type 'Microsoft.Office.Interop.Outlook.Recipients' could be
found (are you missing a using directive or an assembly reference?)"
 
Thanks Ken, that works.

Ken Slovak - said:
In C# it would be mail1.Recipients[1].




Mark B said:
"Error 7 'Microsoft.Office.Interop.Outlook.Recipients' does not contain a
definition for 'Item' and no extension method 'Item' accepting a first
argument of type 'Microsoft.Office.Interop.Outlook.Recipients' could be
found (are you missing a using directive or an assembly reference?)"
 
Back
Top