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());
}