Read MS Outlook PST Files in C# .NET

A Personal Folders File (.pst) is an Outlook data file that stores your messages and other items on your computer. This is the most common file in which information in Outlook is saved. You can export, backup, restore, and password protect a PST file using Outlook itself. Some Outlook users like to keep their PST files password protected to ensure the possibility of snooping to zero. It is possible to protect any PST file in Outlook:

  1. Open Outlook and go to File > Account Settings > Account Settings.
  2. In the Account Settings window, select the PST file whose password you want to set. Then click Settings.
  3. In the Outlook Data File window, click the Change Password button.

In this article, we will learn how to work with password protected pst files in C# .NET.

How does it work internally?

One interesting thing about password-protected Outlook PST files is that the protection is actually only implemented in Outlook; the data streams are not encrypted at all. And it makes it possible to use some API to reset the password or extract emails without knowing the password with APIs like Aspose.Email for .NET.

C# .NET API to Work with Password-Protected PST Files

Aspose.Email for .NET is a robust API that provides a range of features to implement email applications. Also, it allows reading and modifying pst and ost files and other mail storage formats such as MBOX, OLM. You can either install the library via NuGet or download its DLL.

PM> Install-Package Aspose.Email

Read Password-Protected PST Files

With Aspose.Email you can read password-protected files just like regular unprotected pst files.

Check if a PST file is Password-Protected

The API provides the PersonalStorage.Store.IsPasswordProtected property. The PersonalStorage.Store.IsPasswordProtected property returns true if the PST file is password protected and false if it is not.

To check if a file is password-protected, follow these steps:

Validate a Password in Password-Protected PST

The PersonalStorage.Store.IsPasswordValid() method takes the string password as a parameter and returns true if the password is correct and false if it is incorrect.

To validate a password, follow these steps:

Adding, Changing or Removing Password on PST Files

The PersonalStorage.Store.ChangePassword() method is used to add, change or delete a password.

To do this, follow these steps:

Get a Free API License

You can get a free temporary license to use Aspose.Email for .NET without evaluation limitations.


In this article you have learned how to manage password-protected files using C#. Furthermore, you have seen how to read folder information, read emails, and extract items from a PST file in C#. Besides, you can explore more about Aspose.Email for .NET using documentation. Also, you can share your questions or queries on our forum.

See Also