Hi all

I need help to read outlook pst file from java.My pst file is stored in local hard disk.Now i want my java program to read that pst file.Kindly provide some inputs so as to proceed to the solution for the said problem.Can i do this through javamail api?

Thanks and regards
Umadas

It's just a file, so reading it using the standard Java IO API should be child's play.
Figuring out what all those bytes mean is going to be more tricky, but I'm pretty sure someone's done that already and published the file format specification for you to find using your favourite search engine.
It's also more than likely that that search engine could find you a library that does that decoding for you.

Keep in mind that outlook will lock the pst file, so your java program won't be able to access it at the same time if you have outlook running. This link appears to give a good description of the file's format.

http://www.five-ten-sg.com/libpst/rn01re04.html

Upon further reading, those files can be up to 2GB in size, nothing you would want to load in memory all at once. Just a little tidbit of info if you do plan on writing your own pst parser.

Hi all

I need help to read outlook pst file from java.My pst file is stored in local hard disk.Now i want my java program to read that pst file.Kindly provide some inputs so as to proceed to the solution for the said problem.Can i do this through javamail api?

Thanks and regards
Umadas

I was wondeirng if you managed to do this I am trying to do a pst editor with some difficulty

Hi there primbech and welcome to Daniweb,

What specific difficulties are you having with your pst editor? Maybe post some of your code and we will try to help. :)

Hi all

I need help to read outlook pst file from java.My pst file is stored in local hard disk.Now i want my java program to read that pst file.Kindly provide some inputs so as to proceed to the solution for the said problem.Can i do this through javamail api?

Thanks and regards
Umadas

There is a library to read 32-bit and 64-bit .pst files. Here you will find examples JPST

package example;
import com.pff.*;
import java.util.*;

public class Test {
        public static void main(String[] args)
        {
                new Test(args[0]);
        }

        public Test(String filename) {
                try {
                        PSTFile pstFile = new PSTFile(filename);
                        System.out.println(pstFile.getMessageStore().getDisplayName());
                        processFolder(pstFile.getRootFolder());
                } catch (Exception err) {
                        err.printStackTrace();
                }
        }

        int depth = -1;
        public void processFolder(PSTFolder folder)
                        throws PSTException, java.io.IOException
        {
                depth++;
                // the root folder doesn't have a display name
                if (depth > 0) {
                        printDepth();
                        System.out.println(folder.getDisplayName());
                }

                // go through the folders...
                if (folder.hasSubfolders()) {
                        Vector<PSTFolder> childFolders = folder.getSubFolders();
                        for (PSTFolder childFolder : childFolders) {
                                processFolder(childFolder);
                        }
                }

                // and now the emails for this folder
                if (folder.getContentCount() > 0) {
                        depth++;
                        PSTMessage email = (PSTMessage)folder.getNextChild();
                        while (email != null) {
                                printDepth();
                                System.out.println("Email: "+email.getSubject());
                                email = (PSTMessage)folder.getNextChild();
                        }
                        depth--;
                }
                depth--;
        }

        public void printDepth() {
                for (int x = 0; x < depth-1; x++) {
                        System.out.print(" | ");
                }
                System.out.print(" |- ");
        }
}

Nataraj D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.