Skip to end of metadata
Go to start of metadata
Contents Summary
  

Working with PST Password Protection Properties

Microsoft Outlook lets users password protect PST files to restrict access to them. Aspose.Email can detect password protection on a PST file. This article shows how to:

Check for Password protection

The MapiPropertyTag.PR_PST_PASSWORD value from the MapiPropertyTag class is used to check if a file is password protected. The CRC-32 hash of the password string is stored in the PidTagPstPassword (tag = 0x67ff0003) property in the MessageStore. If this property exists and is nonzero, then the PST is password protected. The following code snippet shows you how to check if the PST is password protected. It also shows how to check whether the provided password is correct or not.

 

Removing/Reseting PR_PST_PASSWORD Property

Removal of the PR_PST_PASSWORD property cannot be achieved as other properties are removed from a message store. Instead, we need to set its value to zero (0) in order to get it removed. The "Store" property of the PST class allows access to the store properties of PST instead of MessageStoreProperties of PST in this case. The following code snippet shows you how to Remove/Reset PR_PST_PASSWORD Property.

 

Setting Password on PST Files

The following code snippet shows you how to set a password on PST files.

 

Password Verification for Password Protected PST Files

Aspose.Email enables the developers to check if the PST file is password protected and to check if the given password is correct or not. For this, the API provides the PersonalStorage.Store.IsPasswordProtected property and PersonalStorage.Store.IsPasswordValid() method. The PersonalStorage.Store.IsPasswordProtected property returns true if the PST file is password protected and false if it is not. The PersonalStorage.Store.IsPasswordValid() method which takes the string password as a parameter and returns true if the password is correct and false it is incorrect.

The following code snippet demonstrates the use of PersonalStorage.Store.IsPasswordProtected property and PersonalStorage.Store.IsPasswordValid() method.

Sample Code

Console Output

The storage is password protected - True
Password is valid - True

Labels
  • No labels