تجزیه فایلهای پیام 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());
}