+1 vote

Hi,

Why I can’t see the property "To[0].Address"? and only "To[0].Name"?

by

1 Answer

0 votes
 
Best answer

IMail.To collection is of MailAddress type.

MailAddress is a base class for MailBox and MailGroup, representing single email address and email group. Name property is common to both and is exposed by MailAddress base class.

To access MailBox.Address property (exposed by MailBox sub-class only), you'll need to find all instances of MailBox in this collection or use MailAddress.GetMailboxes() method:

IMail mail = ...;
foreach (MailAddress address in mail.To)
{
    foreach (MailBox mailbox in address.GetMailboxes())
    {
        Console.WriteLine("{0} <{1}>", mailbox.Name, mailbox.Address);
    }    
}

You can find all details on how to work with To, Cc, Bcc email fields here.

by (301k points)
...