Парсинг файлів повідомлень Microsoft Outlook
Contents
[
Hide
]
За допомогою Aspose.Email ви можете розпарсити повідомлення Microsoft Outlook всього за кілька рядків коду. У цій статті показано, як це зробити. Aspose.Email містить класи для виконання різноманітних програмних задач з Outlook‑повідомленнями. Нижчий приклад коду демонструє, як:
- Завантажте лист.
- Отримайте тему листа.
- Отримайте ім’я відправника.
- Отримайте повне тіло листа.
- Перевірте, чи є вкладення.
- Отримайте імена файлів усіх вкладень і збережіть їх.
Наведений фрагмент коду показує, як парсити файли повідомлень Microsoft Outlook.
// The path to the File directory and Load Microsoft Outlook email message file
String dataDir = "data/";
MapiMessage msg = MapiMessage.fromFile(dataDir + "message3.msg");
// Obtain subject of the email message, sender, body and Attachment count
System.out.println("Subject:" + msg.getSubject());
System.out.println("From:" + msg.getSenderName());
System.out.println("Body:" + msg.getBody());
System.out.println("Attachment Count:" + msg.getAttachments().size());
// Iterate through the attachments
for (MapiAttachment attachment : msg.getAttachments()) {
// Access the attachment's file name and Save attachment
System.out.println("Attachment:" + attachment.getFileName());
attachment.save(dataDir + attachment.getLongFileName());
}