Working with MapiTask in PST
Contents
[
Hide
]
Adding MapiTask 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 MapiTask to the Tasks subfolder of a PST file that you have created or loaded.
Below are the steps to add MapiTask to a PST:
- Create a MapiTask object.
- Set the MapiTask properties using constructor and different methods.
- Create a PST using the PersonalStorage.create() method.
- Create a pre-defined folder (Tasks) 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 MapiTask and then add it to the Tasks 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 | |
MapiTask task = new MapiTask("To Do", "Just click and type to add new task", new Date(), new Date()); | |
task.setPercentComplete(20); | |
task.setEstimatedEffort(2000); | |
task.setActualEffort(20); | |
task.setHistory(MapiTaskHistory.Assigned); | |
task.setLastUpdate(new Date()); | |
task.getUsers().setOwner("Darius"); | |
task.getUsers().setLastAssigner("Harkness"); | |
task.getUsers().setLastDelegate("Harkness"); | |
task.getUsers().setOwnership(MapiTaskOwnership.AssignersCopy); | |
PersonalStorage pst = PersonalStorage.create(dataDir + "TaskPST_out.pst", FileFormatVersion.Unicode); | |
FolderInfo taskFolder = pst.createPredefinedFolder("Tasks", StandardIpmFolder.Tasks); | |
taskFolder.addMapiMessageItem(task); |