Phân tích Tệp Tin Nhắn Microsoft Outlook

Contents
[ ]

Với Aspose.Email, bạn có thể phân tích các tin Outlook chỉ bằng một vài dòng mã. Bài viết này chỉ cách thực hiện. Aspose.Email có các lớp để thực hiện nhiều tác vụ lập trình với tin Outlook. Ví dụ mã dưới đây cho thấy cách:

  1. Tải một tin email.
  2. Lấy tiêu đề email.
  3. Lấy tên người gửi.
  4. Lấy nội dung toàn bộ tin.
  5. Kiểm tra xem có tệp đính kèm hay không.
  6. Lấy tên tệp của các tệp đính kèm và lưu chúng.

Đoạn mã dưới đây cho bạn thấy cách phân tích các tệp tin tin nhắn 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());
}