Learn how to read MS Outlook MSG files in C#: https://blog.aspose.com/2022/01/18/read-outlook-msg-emails-in-csharp/
Last active
January 18, 2022 12:27
-
-
Save aspose-com-gists/15d4d3b09aa68953fc2c7106aa764aab to your computer and use it in GitHub Desktop.
Read Outlook MSG Files in C# .NET
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
// Create an instance of MailMessage from file | |
MailMessage message = MailMessage.Load("sample.msg"); | |
// Iterate through the attachments collection | |
foreach (var attachment in message.Attachments) | |
{ | |
// Save the attachment | |
attachment.Save(attachment.Name); | |
} |
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
// Create an instance of MailMessage from file | |
MailMessage message = MailMessage.Load("sample.msg"); | |
// Get subject | |
Console.WriteLine("Subject:" + message.Subject); | |
// Get from address | |
Console.WriteLine("From:" + message.From); | |
// Get body | |
Console.WriteLine("Body" + message.Body); | |
// Get recipients information | |
Console.WriteLine("Recipient: " + message.To); | |
// Get attachments | |
foreach (var att in message.Attachments) | |
{ | |
Console.Write("Attachment Name: " + att.Name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment