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 = mail.Headers.GetRaw("X-Outlook-SentRepresentingName");
string fromAdress = mail.Headers.GetRaw("X-Outlook-SentRepresentingEmailAddress");
string fromAdressType = mail.Headers.GetRaw("X-Outlook-SentRepresentingAddressType");
string senderName = mail.Headers.GetRaw("X-Outlook-SenderName");
string senderAdress = mail.Headers.GetRaw("X-Outlook-SenderEmailAddress");
string senderAdressType = mail.Headers.GetRaw("X-Outlook-SenderAddressType");
for (int i = 0; i < int.MaxValue; i++)
{
string recipientType = mail.Headers.GetRaw(string.Format("X-Outlook-Recipient{0}-Type", i));
string recipientName = mail.Headers.GetRaw(string.Format("X-Outlook-Recipient{0}-Name", i));
string recipientSmtpAdress = mail.Headers.GetRaw(string.Format("X-Outlook-Recipient{0}-SmtpAddress", i));
string recipientAdress = mail.Headers.GetRaw(string.Format("X-Outlook-Recipient{0}-EmailAddress", i));
string recipientAdressType = mail.Headers.GetRaw(string.Format("X-Outlook-Recipient{0}-AddressType", i));
if (recipientType == null)
break;
}
Current trial build with this functionality can be downloaded here
answered
01 Mar '11, 16:59
Lukas Matyska ♦♦
901●1●7
accept rate:
28%
.msg saved from Outlook can contain addresses like /O=REBEXCR/OU=FIRST ADMINISTRATIVE GROUP/CN=RECIPIENTS/CN=JAN.SOTOLA
Is this what you want to retrieve?
Yes. That is what is stored in my .msg files. I need the associated email addresses (or even just that string and I can do the lookup myself) for printing reasons.