Read and Convert Outlook OST Files

Aspose.Email for Python via .NET provides the API for reading Microsoft Outlook OST files. You can load an OST file from disk or a stream into an instance of the PersonalStorage class and get information about its contents, for example, folders, subfolders and messages. Microsoft Outlook creates a PST file to store emails when using POP3 or IMAP mail servers for downloading messages, whereas an OST file is created when Microsoft Exchange is the mail server. OST files are designed to support larger file sizes compared to PST files.

Reading OST Files

The process for reading an OST file with Aspose.Email is exactly the same as for reading a PST file. The same code can read both PST and OST files: just provide the correct file name to the PersonalStorage.from_file() method. The following code snippet shows you how to read OST files:

from aspose.email.storage.pst import PersonalStorage

with PersonalStorage.from_file(data_dir + "PersonalStorageFile.ost") as pst:
    # Get the format of the file
    print("File format of the OST:", pst.format)

Convert OST to PST

Aspose.Email makes it possible to convert an OST file to PST with a single line of code. The target format is given by a value of the FileFormat enumeration. At present, the API supports converting OST formats to PST except OST 2013/2016. The following code snippet shows you how to convert OST to PST:

from aspose.email.storage.pst import PersonalStorage, FileFormat

with PersonalStorage.from_file(data_dir + "PersonalStorageFile.ost") as pst:
    pst.save_as(data_dir + "ConvertOSTToPst_out.pst", FileFormat.PST)

Convert PST to OST

Conversion from PST to OST is not supported by Aspose.Email because OST is always created by the Outlook when adding an account and synchronizing with the mail server. The difference between PST and OST files is that PST is only available locally. OST content is also available on the e-mail server. So there is no need to convert PST to OST for local use. But you can import PST into an existing account using the Import/Export wizard in Outlook.

For performing other operations with OST files, please refer to the following pages: