Read Outlook PST and Get Folders and Subfolders Information
Contents
[
Hide
]
Aspose.Email - Read Outlook PST and Get Folders and Subfolders Information
Aspose.Email for Java lets you read Microsoft Outlook PST files. You can load a PST file from disk or stream into an instance of the PersonalStorage class and get the information about its contents, for example folders, subfolders and messages.
After loading the PST file into the PersonalStorage class, you can get the information about the file display name, root folder, subfolders and messages count.
Java
// Load the Outlook PST file
PersonalStorage pst = PersonalStorage.fromFile(dataDir + "personalStorage.pst");
// Get the Display Name of the PST file
System.out.println("Display Name: " + pst.getDisplayName());
// Get the folders information
FolderInfoCollection folderInfoCollection = pst.getRootFolder().getSubFolders();
// Browse through each folder to display folder name and number of messages
for (int i = 0; i < folderInfoCollection.size(); i++)
{
FolderInfo folderInfo = (FolderInfo) folderInfoCollection.get_Item(i);
System.out.println("Folder: " + folderInfo.getDisplayName());
System.out.println("Total items: " + folderInfo.getContentCount());
System.out.println("Total unread items: " + folderInfo.getContentUnreadCount());
System.out.println("-----------------------------------");
}
Download Running Code
Download Sample Code
For more details, visit Read Outlook PST File and Get Folders and Subfolders Information.