We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to get special folders

HI There

How can I re-implement this getMailboxRootAspose() function so that it will work for PST’s created in any language and version of Outlook… Is there a way to get FolderInfo reference to special folder objects in a PST file without referencing folderInfo.getDisplayName()?

PST FIle: Top of Personal Folders
OST File: Root - Mailbox, PM_SUBTREE

private FolderInfo getMailboxRootAspose(FolderInfo folder) {

    String folderName = folder.getDisplayName();
    MessageImportProcess.ImportFileType importFileType = ((MessageImportProcess) getProcess()).getImportFileType();
    switch (importFileType) {
        case PST:
            if (folderName.startsWith("Top of")) {
                return folder;
            return folder;
        case OST:
            FolderInfo ipmFolder;
            try {
                ipmFolder = findFolderAspose(folder, "Root - Mailbox");
                if (ipmFolder != null)
                    ipmFolder = findFolderAspose(ipmFolder, "IPM_SUBTREE");
                if (ipmFolder != null)
                    return ipmFolder;
            } catch (Exception io) {
                logger.error("failed to retrieve folder:" + io.getMessage(), io);
    if (folder.hasSubFolders()) {
        try {
            FolderInfoCollection childFolders = folder.getSubFolders();
            for (int i = 0; i < childFolders.size(); i++) {
                FolderInfo foundMailboxRoot = childFolders.get_Item(i);
                if (foundMailboxRoot != null) {
                    return foundMailboxRoot;
        } catch (Exception io) {
            logger.error("failed to retrieve folder:" + io.getMessage(), io);
    return null;




The code sample shared in our docs, Getting Messages Information from PST file, illustrates how to traverse recursively over a PST file and get messages information. If it doesn’t meet you requirements, please share your PST file and code (without your specific types) with us that we can try at our end for assisting you further.

It doesn’t meet my needs. See the code above. It works with English PST files, but not Italian. Why? because the special folder “Top of Personal Folders”, is in Italian when working with Italian PST files. I need to be able to get a reference to that folder that will work for PST’s created in any language. How do I get this reference in a locale independent way?

here are the list of special folders:


How do I get them without referencing an English name to retrieve them so that it will work with PST files created in different languages?


Please share a sample PST with us having non-english names of such folders so that we can analyze your requirements in detail.

https://cp.sync.com/dl/80db9a2a0#67wz8xgt-tetq3tfu-5umkatrd-z6qwb8mx Please don’t ask for password. I don’t have it. Aspose does read the file fine and I can see entries in there, one of which is the Italian equivalent of Top of Personal Folders.


When we open your file in MS Outlook, we only see these folders in your PST file: 2018_07_17_19_58_05_File_di_dati_di_Outlook_Outlook.png (16.8 KB)
Can you please share which folder of these you want to get using the API? When following code is used, it lists all the folders and files from the PST file successfully.


public static void ReadPstFile()

	String pstFileName = "Jamie.pst";
	// load the Outlook PST file
	PersonalStorage pst = PersonalStorage.fromFile(pstFileName);
	FolderInfo folderInfo = pst.getRootFolder();
	// call the recursive method to display the folder contents
	displayFolderContents(folderInfo, pst);

private static void displayFolderContents(FolderInfo folderInfo, PersonalStorage pst) {
	// display the folder name
	System.out.println("Folder: " + folderInfo.getDisplayName());
	// display information about messages inside this folder
	MessageInfoCollection messageInfoCollection = folderInfo.getContents();
	for (int i = 0; i < messageInfoCollection.size(); i++) {
		MessageInfo messageInfo = (MessageInfo) messageInfoCollection.get_Item(i);
		System.out.println("Subject: " + messageInfo.getSubject());
		System.out.println("Sender: " + messageInfo.getSenderRepresentativeName());
		System.out.println("To: " + messageInfo.getDisplayTo());
		System.out.println("CC: " + messageInfo.getDisplayCC());
		System.out.println("EntryID: " + messageInfo.getEntryIdString());

	// call this method recursively for each subfolder
	if (folderInfo.hasSubFolders() == true) {
		for (int i = 0; i < folderInfo.getSubFolders().size(); i++) {
			FolderInfo subfolderInfo = (FolderInfo) folderInfo.getSubFolders().get_Item(i);
			displayFolderContents(subfolderInfo, pst);

its not a question of listing items in the PST. I know we can do that. Its a case of retrieving special folders as defined as https://msdn.microsoft.com/en-us/library/hh354773(v=exchg.80).aspx in a manner that is independent of the locale of the PST.

For example, I would assume that there would be a unique identifier that could identify a specific special folder irrespective of locale. For instance, that there would be a definition of special folders somewhere in Aspose PST code. For example,

public static final int INBOX_FOLDER = [id];
public static final int TOP_OF_PERSONAL_FOLDERS = [id];
etc… for each of the special folder defined at https://msdn.microsoft.com/en-us/library/hh354773(v=exchg.80).aspx So that you could retrieve a special folder easily and this could occur irrespective of the locale of the PST.

Incidentally, as a separate issue, I am not sure if this related to the PST’s I have been working with, but the Inbox folder is supposed to have the IPF.NOTE container class assigned to it. When I parse PST files, the container class is empty. According to the docs, the container class should only be empty for Root,Finder,FreeBusy Data, Top of Personal Folders. Other folder structures should have the container class specified.


We believe you want to get the predefined folders represented by API by StandardIpmFolder. However, these are limited to as shown the available link.

You can get these using getPredefinedFolder method of PST as shown below:

FolderInfo fi = pst.getPredefinedFolder(StandardIpmFolder.Inbox);

Regarding your query related to IP.NOTE class, we are looking into it and will soon update you here with our findings.

Those predefined folders are not exactly what I need. I am looking for Top Of Personal Folders specifically. You should have predefined folders for the entries specified at https://msdn.microsoft.com/en-us/library/hh354773(v=exchg.80).aspx


We are analyzing your requirements and will get back to you for possibility of making any such information available to you.


For PST, root folder is “Top of Personal Folders”:

FolderInfo TopOfPersonalFolders = pst.getRootFolder();

While for OST, Root - Mailbox and PM_SUBTREE have persistent ids, and below is the code to get these folders:

PersonalStorage ost = null;
byte[] recordKey = ost.getStore().getProperties().get_Item(MapiPropertyTag.PR_RECORD_KEY).getData();
FolderInfo RootMailbox = ost.getFolderById(toEntryId(0x20a2, recordKey));
FolderInfo IPM_SUBTREE = ost.getFolderById(toEntryId(0x2142, recordKey));

public static byte[] toEntryId(int id, byte[] recordKey)
    byte[] result = new byte[24];
    System.arraycopy(recordKey, 0, result, 4, recordKey.length);
    System.arraycopy(com.aspose.email.system.BitConverter.getBytesUInt32(id), 0, result, 20, 4);
    return result;

Please let us know if we could be of any additional help to you in this regard.