This short tutorial guides on how to split PST File using Python by exposing the references for establishing the environment and a program flow to achieve the goal. You will learn to split Outlook PST file using Python with the help of a few lines of code that can be used in any Python supported environment including Windows and Linux.
Steps to Develop PST Splitter using Python
- Configure the environment to use Aspose.Email for Python via .NET in your application to split a PST file in Python
- Add the aspose.email namespace in Python file to perform splitting of PST file
- Create a PersonalStorageQueryBuilder object to add multiple query criteria
- Append the PersonalStorageQueryBuilder query criteria in the MailQuery list
- Create the PersonalStorage class instance to load the source PST file from the disk and perform the split operation
- Split the loaded PST file to multiple PST files based on the selected criteria using the split_into method
The aforementioned steps describe the simple process to develop an Outlook PST splitter using Python, whereby PersonalStorageQueryBuilder can be used to define the criteria for splitting the PST based on the query parameters. The queries are appended to a MailQuery list, which set the PST splitting criteria inside the split_into method after accessing the source PST file from the disk using the PersonalStorage class.
Code to Split PST File using Python
This example demonstrates that in order to develop an application to split PST using Python, a simple API interface can be used with the help of simple API calls. The process is very easy and involves declaring the queries first that serve as criteria for splitting the PST file, which is then followed by accessing the source PST from the disk. Finally, by using the split_into method the PST is split into multiple PST files on the disk.
In this article, we have learnt in detail about splitting a PST using Python. If you want to learn about converting an email to a Word document in Python, refer to the article on how to convert Outlook Email to Word using Python.