We added new option LoadMsgProperties
to enable retrieving of various MSG properties. This code can be used to retrieve all supported MSG properties:
// load MSG into mail message
MailMessage mail = new MailMessage();
mail.Options = Rebex.Mime.MimeOptions.LoadMsgProperties;
mail.Load("mail.msg");
// get required properties
// AdressType is typically from set {EX, SMTP}
// RecipientType is typically from set {To, Cc, Bcc}
string fromName = GetHeader(mail, "X-Outlook-SentRepresentingName");
string fromAdress = GetHeader(mail, "X-Outlook-SentRepresentingEmailAddress");
string fromAdressType = GetHeader(mail, "X-Outlook-SentRepresentingAddressType");
string senderName = GetHeader(mail, "X-Outlook-SenderName");
string senderAdress = GetHeader(mail, "X-Outlook-SenderEmailAddress");
string senderAdressType = GetHeader(mail, "X-Outlook-SenderAddressType");
for (int i = 0; i < int.MaxValue; i++)
{
string recipientType = GetHeader(mail, string.Format("X-Outlook-Recipient{0}-Type", i));
string recipientName = GetHeader(mail, string.Format("X-Outlook-Recipient{0}-Name", i));
string recipientSmtpAdress = GetHeader(mail, string.Format("X-Outlook-Recipient{0}-SmtpAddress", i));
string recipientAdress = GetHeader(mail, string.Format("X-Outlook-Recipient{0}-EmailAddress", i));
string recipientAdressType = GetHeader(mail, string.Format("X-Outlook-Recipient{0}-AddressType", i));
if (recipientType == null)
break;
}
private static string GetHeader(MailMessage mail, string headerName)
{
MimeHeader h = mail.Headers[headerName];
if (h == null || h.Value == null)
return null;
else
return h.Value.ToString();
}
Current trial build with this functionality can be downloaded here.