การแยกไฟล์ข้อความ Microsoft Outlook

Contents
[ ]

ด้วย Aspose.Email คุณสามารถแยกไฟล์ข้อความ Microsoft Outlook ได้เพียงไม่กี่บรรทัดของโค้ด บทความนี้แสดงวิธีทำ Aspose.Email มีคลาสสำหรับทำงานโปรแกรมหลายอย่างกับข้อความ Outlook ตัวอย่างโค้ดด้านล่างแสดงวิธี:

  1. โหลดข้อความอีเมล.
  2. รับหัวข้ออีเมล.
  3. รับชื่อผู้ส่ง.
  4. รับเนื้อความเต็มของข้อความ.
  5. ตรวจสอบว่ามีไฟล์แนบหรือไม่.
  6. รับชื่อไฟล์ของไฟล์แนบใด ๆ และบันทึกไว้.

โค้ดตัวอย่างต่อไปนี้แสดงวิธีแยกไฟล์ข้อความ 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());
}