+1 vote

I do have a follow up question. We are currently using the library to extract data from outlook .msg files and having issues with retreiving the To and Cc information.

Though we can see the correct data in the To field (using debugger), we can not access anything else but the To[i].Name. Same applies for the Cc attribute.

It does work as expected with the From field.

by

1 Answer

0 votes
 
Best answer

IMail To, Cc, Bcc and ReplyTo properties are of IList type.
The reason for this, is to handle not only regular mailboxes but also email groups:

public class MailBox : MailAddress
public class MailGroup : MailAddress

The simplest way to access actual email addresses is to use overloaded
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 more info here:
https://www.limilabs.com/blog/how-to-access-to-cc-bcc-fields

by (282k points)
...