Skip to content

Instantly share code, notes, and snippets.

@documentprocessing
Created October 29, 2024 15:46
Show Gist options
  • Save documentprocessing/7666972fc8b9066816648e47876cd670 to your computer and use it in GitHub Desktop.
Save documentprocessing/7666972fc8b9066816648e47876cd670 to your computer and use it in GitHub Desktop.
Read EML file using MSGReader API
var fileInfo = new FileInfo("d:\\testfile.eml");
var eml = MsgReader.Mime.Message.Load(fileInfo);
if (eml.Headers != null)
{
if (eml.Headers.To != null)
{
foreach (var recipient in eml.Headers.To)
{
var to = recipient.Address;
}
}
}
var subject = eml.Headers.Subject;
if (eml.TextBody != null)
{
var textBody = System.Text.Encoding.UTF8.GetString(eml.TextBody.Body);
}
if (eml.HtmlBody != null)
{
var htmlBody = System.Text.Encoding.UTF8.GetString(eml.HtmlBody.Body);
}
// etc...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment