Search code examples
c#emailoutlookemlpst

Convert PST into multiple EML files in C#


I need to create an application that parses a PST file and converts the mails into multiple EML files. Basically, I need to do the opposite of what's being asked in this question.

Is there any sample code or guidelines to achieve this feature?


Solution

  • You need essentially to do the inverse of what is being asked in that question.

    • Load the PST file using Outlook interop (or redemption as above)
    • Enumerate all the files.
    • Use CDO, System.Mail or similar to compose an EML file for each file in the PST.

    The thing to note is that a PST doesn't contain EML files, it contains MSG files. So you will have to do some form of conversion, and you will not get back exactly what was originally sent.

    See also this question: Are there .NET Framework methods to parse an email (MIME)?