Парсинг файлов сообщений Microsoft Outlook

Contents
[ ]

С помощью Aspose.Email вы можете парсить сообщения Microsoft Outlook всего в несколько строк кода. Эта статья покажет вам как. Aspose.Email содержит классы для выполнения многих программных задач с сообщениями Outlook. Приведенный ниже пример кода демонстрирует, как:

  1. Загрузить электронное сообщение.
  2. Получить тему письма.
  3. Узнать имя отправителя.
  4. Получить полный текст сообщения.
  5. Выяснить, есть ли вложения.
  6. Получить имена файлов всех вложений и сохранить их.

Следующий фрагмент кода покажет, как парсить файлы сообщений Microsoft Outlook.

// 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);
}