Is there a way to get the correct "From" property when loading a .msg file from disk that contains an Active Directory address (I have seen via other means that the .msg's display name is the user's full name, and the email address is what looks like a Active Directory query)?

asked 26 Feb '11, 01:05

Josh%20Zacharias's gravatar image

Josh Zacharias
181
accept rate: 0%

.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?

(28 Feb '11, 10:16) Lukas Matyska ♦♦

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.

(28 Feb '11, 23:57) Josh Zacharias

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

link

answered 01 Mar '11, 16:59

Lukas%20Matyska's gravatar image

Lukas Matyska ♦♦
90117
accept rate: 28%

edited 11 Mar '11, 18:19

I wrote this to do a mass convert from EML to MSG

public void Start(string DirectoryPath)
    {
        MailMessage message = new MailMessage();
        string fileName = string.Empty;
        Console.WriteLine("Starting Convertion!");
        foreach (string f in Directory.GetFiles(DirectoryPath, "*.eml"))
        {
            fileName = System.IO.Path.GetFileNameWithoutExtension(f);
            Console.WriteLine("Converting: " + f);
            message.Load(f);
            message.Save(DirectoryPath+"\\"+fileName + ".msg", MailFormat.OutlookMsg);
        }
        Console.WriteLine("Files Converted!");
    }
link

answered 08 Aug '11, 22:18

Ranch%20Camalalingam's gravatar image

Ranch Camala...
151
accept rate: 0%

edited 08 Aug '11, 22:19

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×53

Asked: 26 Feb '11, 01:05

Seen: 778 times

Last updated: 08 Aug '11, 22:19