1. Products
  2.   Email
  3.   Java
  4.   Java-libpst  
 
  

Process Outlook PST Files via Open Source Java API

Read & Extract the content of Outlook PST files without using Microsoft Outlook via Free Java Library.

What is Java-libpst?

Java-libpst is an open source Java library for reading and extracting contents of Outlook PST files. PST is a very popular file format used by MS Outlook for storing emails. It is used to archive message copies, attachments, calendar events, contacts, and other Outlook items. Java-libpst enables developers to access and extract all this information so that it may be migrated or used in other systems.

The library has much improved with the passage of time. It now allows developers to handle large PST files with reasonable speed, compressible encryption support, ANSI (32bit) support, Unicode (64bit) Outlook PST and Exchange OST support & much more.

Previous Next

Getting Started with Java-libpst

First of all, you need to install JDK 1.6 or higher.

Dependency that needs to be added to pom.xml file is,

Maven Dependency

<!-- https://mvnrepository.com/artifact/com.pff/java-libpst -->
<dependency>
  <groupId>com.pff</groupId>
  <artifactId>java-libpst</artifactId>
  <version>0.9.3</version>
</dependency>

You can download the library directly from GitHub page.

Load & Parse PST Files via Java

Java-libpst library allows to load & parse PST with the functionality to iterate over the PST folders and email collection within each folder. It also allows users to get email details, like subject, body, HTML body, recipient list, and so on.

  1. Load PST file via PSTFile constructor
  2. Get root folder with the help of PSTFile.getRootFolder() method
  3. Get children of root folder which are email messages
  4. Store each email in an instance of PSTMessage
  5. Parse email subject, body and so on for further processing

How to Parse PST Files via Java?

// Open sample PST
PSTFile pstFile = new PSTFile("sample.pst");
// Get display name
System.out.println(pstFile.getMessageStore().getDisplayName());

// Read emails in folder
if (pstFile.getRootFolder().getContentCount() > 0) {
  PSTMessage email = (PSTMessage)pstFile.getRootFolder().getNextChild();
  while (email != null) {
    System.out.println("Email: "+email.getSubject());
    email = (PSTMessage)pstFile.getRootFolder().getNextChild();
  }

}

Extract Email Addresses from PST File in Java Apps

java-libpst API enables Java developers to extract email addresses and other details from PST files inside their own Java applications. Developers can easily go through every email and read the mail which is an attachment of an email.

 English