This short tutorial guides on how to split PST File using C# 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 C# with the help of a few lines of code that can be used in any of .NET supported environments including Windows, macOS and Linux.
Steps to Develop PST Splitter using C#
- Set up the development environment to include Aspose.Email for .NET from NuGet package manager
- Add the Aspose.Email namespace in your source file
- Instantiate the PersonalStorageQueryBuilder object to create multiple query criteria
- Add the PersonalStorageQueryBuilder query criteria inside the MailQuery list
- Instantiate the PersonalStorage class instance to load the source PST file from the disk
- Split the PST to multiple PST files based on the selected criteria using the SplitInto method
The aforementioned steps describe the simple process to develop an Outlook PST splitter using C#, whereby PersonalStorageQueryBuilder can be used to define the criteria for splitting the PST based on the query parameters. The queries are added to the MailQuery list, which serves as PST splitting criteria inside the SplitInto method after loading the source PST file from the disk using the PersonalStorage class.
Code to Split PST File using C#
This example demonstrates that in order to develop an application to split PST using C#, a simple API interface can be used with the help of simple API calls. The process is very simple whereby we first define the queries which serve as criteria for splitting the PST file, which is then followed by loading the PST from the disk. Finally, by using the SplitInto 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 C#. If you want to learn about converting an OST file to a PST file in C#, refer to the article on how to convert OST to PST file in C#.