在 PST 中使用 MapiNote
Contents
[
Hide
]
向 PST 添加 MapiNote
创建新 PST,添加子文件夹和邮件 展示了如何创建 PST 文件并添加子文件夹。使用 Aspose.Email,您可以向已创建或加载的 PST 文件的 Notes 子文件夹添加 MapiNote。
以下是将 MapiNote 添加到 PST 的步骤:
- 使用 Microsoft Outlook 创建模板 MapiNote 并将其保存为 MSG 文件。
- 将已保存的 MSG 笔记加载到 MapiMessage 对象。
- 创建一个 MapiNote 对象并加载模板 MSG 笔记。
- 设置 MapiNote 使用不同的方法获取属性。
- 使用 PersonalStorage.create() 方法。
- 通过访问根文件夹并调用以下方法,在 PST 文件根目录创建预定义文件夹(Notes)。 addMapiMessageItem() 方法。
下面的代码片段展示了如何创建一个 MapiNote 然后将其添加到新创建的 PST 文件的 Notes 文件夹中。
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java
String dataDir = "data/";
MapiMessage source = MapiMessage.load(dataDir + "Note.msg");
// Note #1
MapiNote note1 = (MapiNote) source.toMapiMessageItem();
note1.setSubject("Yellow color note");
note1.setBody("This is a yellow color note");
// Note #2
MapiNote note2 = (MapiNote) source.toMapiMessageItem();
note2.setSubject("Pink color note");
note2.setBody("This is a pink color note");
note2.setColor(NoteColor.Pink);
// Note #3
MapiNote note3 = (MapiNote) source.toMapiMessageItem();
note3.setSubject("Blue color note");
note3.setBody("This is a blue color note");
note3.setColor(NoteColor.Blue);
note3.setHeight(500);
note3.setWidth(500);
PersonalStorage pst = PersonalStorage.create(dataDir + "MapiNoteToPST_out.pst", FileFormatVersion.Unicode);
FolderInfo notesFolder = pst.createPredefinedFolder("Notes", StandardIpmFolder.Notes);
notesFolder.addMapiMessageItem(note1);
notesFolder.addMapiMessageItem(note2);
notesFolder.addMapiMessageItem(note3);