PST에서 MapiJournal 작업

PST에 MapiJournal 추가

새 PST 생성, 하위 폴더 및 메시지 추가 PST 파일을 생성하고 하위 폴더를 추가하는 방법을 보여주었습니다. Aspose.Email을 사용하면 생성하거나 로드한 PST 파일의 Journal 하위 폴더에 MapiJournal을 추가할 수 있습니다. 아래는 PST에 MapiJournal을 추가하는 단계입니다:

  1. 다음을 생성합니다 MapiJournal 객체.
  2. 설정합니다. MapiJournal 생성자와 메서드를 사용하여 속성을 설정합니다.
  3. 다음을 사용하여 PST를 생성합니다 PersonalStorage.create() 메서드.
  4. 루트 폴더에 접근한 뒤 사전 정의된 폴더(Journals)를 PST 파일의 루트에 생성하고 그 다음에 호출합니다. addMapiMessageItem() 메서드.

아래 코드 스니펫은 생성 방법을 보여줍니다 MapiJournal 그런 다음 새로 만든 PST 파일의 Journal 폴더에 추가합니다.

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
String dataDir = "data/";

Date startTime = new Date();
Date endTime = new Date(startTime.getTime() + 60L * 60 * 1000);

MapiJournal journal = new MapiJournal("daily record", "called out in the dark", "Phone call", "Phone call");
journal.setStartTime(startTime);
journal.setEndTime(endTime);

PersonalStorage pst = PersonalStorage.create(dataDir + "JournalPST_out.pst", FileFormatVersion.Unicode);
FolderInfo journalFolder = pst.createPredefinedFolder("Journal", StandardIpmFolder.Journal);

journalFolder.addMapiMessageItem(journal);

MapiJournal에 첨부 파일 추가

MAPI 저널 항목에 첨부 파일을 추가하는 것도 가능합니다. 아래 코드는 그 방법을 보여줍니다.

// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
String dataDir = "data/";

Date startTime = new Date();
Date endTime = new Date(startTime.getTime() + 60L * 60 * 1000);

MapiJournal journal = new MapiJournal("daily record", "called out in the dark", "Phone call", "Phone call");
journal.setStartTime(startTime);
journal.setEndTime(endTime);

// Add the companies information
journal.setCompanies(new String[] { "Company 1", "Company 2", "Company 3" });

// Add the attachments
for (String name : new String[] { "1.png", "Invitation.doc", "logo.jpg" }) {
    // Read the attachment content into a byte array
    byte[] data = Files.readAllBytes(Paths.get(dataDir + name));

    journal.getAttachments().add(name, data);
}

// Save the journal item as an MSG file
journal.save(dataDir + "JournalWithAttachments_out.msg");