Working with MapiNote in PST
Contents
[
Hide
]
Adding MapiNote to PST
Create New PST, Add Sub-folders and Messages showed how to create a PST file and add a subfolder to it. With Aspose.Email you can add a MapiNote to the Notes subfolder of a PST file that you have created or loaded.
Below are the steps to add MapiNote to a PST:
- Create a template MapiNote using Microsoft Outlook and save it as an MSG file.
- Load saved MSG note into MapiMessage object.
- Create a MapiNote object and load the template MSG note.
- Set the MapiNote properties using different methods.
- Create a PST using the PersonalStorage.create() method.
- Create a pre-defined folder (Notes) at the root of the PST file by accessing the root folder and then calling the addMapiMessageItem() method.
The code snippet below shows how to create a MapiNote and then add it to the Notes folder of a newly created PST file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-Java | |
MapiMessage mess = MapiMessage.fromFile(dataDir + "Note.msg"); | |
// Note #1 | |
MapiNote note1 = (MapiNote) mess.toMapiMessageItem(); | |
note1.setSubject("Yellow color note"); | |
note1.setBody("This is a yellow color note"); | |
// Note #2 | |
MapiNote note2 = (MapiNote) mess.toMapiMessageItem(); | |
note2.setSubject("Pink color note"); | |
note2.setBody("This is a pink color note"); | |
note2.setColor(NoteColor.Pink); | |
// Note #3 | |
MapiNote note3 = (MapiNote) mess.toMapiMessageItem(); | |
note2.setSubject("Blue color note"); | |
note2.setBody("This is a blue color note"); | |
note2.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); |