private void parseFolder(XHTMLContentHandler handler, PSTFolder pstFolder, String folderPath,
                             EmbeddedDocumentExtractor embeddedExtractor) throws Exception {
        if (pstFolder.getContentCount() > 0) {
            PSTMessage pstMail = (PSTMessage) pstFolder.getNextChild();
            while (pstMail != null) {
                Metadata metadata = new Metadata();
                metadata.set(TikaCoreProperties.CONTENT_TYPE_PARSER_OVERRIDE, PSTMailItemParser.PST_MAIL_ITEM_STRING);
                metadata.set(PST.PST_FOLDER_PATH, folderPath);
                try (TikaInputStream tis = TikaInputStream.get(new byte[0])) {
                    tis.setOpenContainer(pstMail);
                    metadata.set(TikaCoreProperties.RESOURCE_NAME_KEY, pstMail.getSubject() + ".msg");
                    embeddedExtractor.parseEmbedded(tis, handler, metadata, true);
                }
                pstMail = (PSTMessage) pstFolder.getNextChild();
            }
        }

        if (pstFolder.hasSubfolders()) {
            for (PSTFolder pstSubFolder : pstFolder.getSubFolders()) {
                handler.startElement("div", createAttribute("class", "email-folder"));
                handler.element("h1", pstSubFolder.getDisplayName());
                String subFolderPath = folderPath.endsWith("/") ? folderPath + pstSubFolder.getDisplayName() :
                        folderPath + "/" + pstFolder.getDisplayName();
                parseFolder(handler, pstSubFolder, subFolderPath, embeddedExtractor);
                handler.endElement("div");
            }
        }
    }
Parser for MS Outlook PST email storage files
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-microsoft-module/src/main/java/org/apache/tika/parser/microsoft/pst/OutlookPSTParser.java