This short tutorial focuses on how to Create a PST file in Python by providing references for establishing the environment and then program flow to perform this task. You will get familiar with the process to create a new PST file in Python with the help of a few lines of code along with the option to insert different types of folders into it.
Steps to Create a PST File in Python
- Establish the environment to use Aspose.Email for Python via .NET in your application to create PST in Python
- Include the aspose.email namespace in Python file
- Create an instance of the PersonalStorage class to create the PST file on the disk
- Add a predefined folder in the root folder of the PST
- Include a custom folder in the root folder
- Save the created PST file on disk
The above mentioned steps describe the process to create a new PST in Python whereby the process will commence by importing the API namespace in your Python file, which is then followed by creating a PST file on the disk using the PersonalStorage class. One can create a PST file by providing the PST file name and the file format version which can be either Unicode or ANSI coded. We may create a PST file without any folder and can insert predefined or custom folders before saving that on the disk.
Code to Create PST in Python
This example has exhibited how to create Outlook PST file in Python by employing one of the overloaded functions create() belonging to PersonalStorage class. You can easily insert predefined folders using the standard_ipm_folder enumerator that contains entries like Inbox, SentItems, Outbox, DeletedItems, Tasks, Contacts, etc. to name a few. You can also add custom folders that are not standard but may be required in your implementation.
This article entails how to make a PST file in Python using the simple API interface. If you are interested in learning about converting an EML file to an MSG file in Python, refer to the article on how to Convert EML to MSG using Python.