Created
October 29, 2024 15:46
-
-
Save documentprocessing/7666972fc8b9066816648e47876cd670 to your computer and use it in GitHub Desktop.
Read EML file using MSGReader API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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