Парсинг файлов сообщений Microsoft Outlook
Contents
[
Hide
]
С помощью Aspose.Email вы можете парсить сообщения Microsoft Outlook всего в несколько строк кода. Эта статья покажет вам как. Aspose.Email содержит классы для выполнения многих программных задач с сообщениями Outlook. Приведенный ниже пример кода демонстрирует, как:
- Загрузить электронное сообщение.
- Получить тему письма.
- Узнать имя отправителя.
- Получить полный текст сообщения.
- Выяснить, есть ли вложения.
- Получить имена файлов всех вложений и сохранить их.
Следующий фрагмент кода покажет, как парсить файлы сообщений Microsoft Outlook.
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
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory and Load Microsoft Outlook email message file | |
string dataDir = RunExamples.GetDataDir_KnowledgeBase(); | |
MapiMessage msg = MapiMessage.FromFile(dataDir + "message3.msg"); | |
// Obtain subject of the email message, sender, body and Attachment count | |
Console.WriteLine("Subject:" + msg.Subject); | |
Console.WriteLine("From:" + msg.SenderName); | |
Console.WriteLine("Body:" + msg.Body); | |
Console.WriteLine("Attachment Count:" + msg.Attachments.Count); | |
// Iterate through the attachments | |
foreach (MapiAttachment attachment in msg.Attachments) | |
{ | |
// Access the attachment's file name and Save attachment | |
Console.WriteLine("Attachment:" + attachment.FileName); | |
attachment.Save(dataDir + attachment.LongFileName); | |
} |