การแยกไฟล์ข้อความ 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());
}