MailMessage - get the "envelope-to" header

Hello,


I’d like to know how to retrieve the addresses contained in the “envelope-to” header of a MailMessage.

For example, when I receive an e-mail aimed to more than 50 recipients, it’s sometimes cut in several e-mail, each containing every original recipient in the “to” header but only the 50 max recipients of the current part in the “envelope-to” header.

Cordially,
AVM Informatique

Hi,

Thank you for inquiry.

If this header is present in the message, you can get it with the following sample code.

MailMessage message = MailMessage.Load(“test.eml”, MessageFormat.Eml);
Console.WriteLine(message.Headers.Get(“envelope-to”));

You may also view all the headers contained in the message by using a for loop as follows:
foreach (string key in message.Headers.AllKeys)
{
Console.WriteLine(key + ": " + message.Headers.Get(key));
}

All the recipients should also be visible using MailMessage.To collection.