How to Split Single PST File into Multiple PSTs & Merge Multiple PSTs using .NET

This technical tip explains how to .NET developers can split and Merge PST files using Aspose.Email. Aspose.Email API provides the capability to split a single PST file into multiple PST files of desired file size. It can also merge multiple PST files into a single PST file. Both the splitting and merging of PSTs operations can be tracked by adding events to these operations. Aspose.Email for .NET is a set of components allowing developers to easily implement email functionality within their ASP.NET web applications, web services & Windows applications. It Supports Outlook PST, EML, MSG & MHT formats. It allows developers to work with SMTP, POP3, FTP & MS Exchange servers.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//your code here...//Code sample for Splitting a Single PST into multiple PSTs
 [C#]
using (PersonalStorage pst = PersonalStorage.FromFile(@"D:\test\source.pst"))
{
    // The events subscription is an optional step for the tracking process only.
    pst.StorageProcessed += PstSplit_OnStorageProcessed;
    pst.ItemMoved += PstSplit_OnItemMoved;
    // Splits into pst chunks with the size of 5mb
    pst.SplitInto(5000000, @"D:\test\chunks\");
}
 
[VB.NET]
Using pst As PersonalStorage = PersonalStorage.FromFile("D:\test\source.pst")
    ' The events subscription is an optional step for the tracking process only.
    pst.StorageProcessed += PstSplit_OnStorageProcessed
    pst.ItemMoved += PstSplit_OnItemMoved
    ' Splits into pst chunks with the size of 5mb
    pst.SplitInto(5000000, "D:\test\chunks\")
//Code sample for Merging of Multiple PSTs into a single PST
 
[C#]
totalAdded = 0;
using (PersonalStorage pst = PersonalStorage.FromFile(@"D:\test\destination.pst"))
{
    // The events subscription is an optional step for the tracking process only.
    pst.StorageProcessed += PstMerge_OnStorageProcessed;
    pst.ItemMoved += PstMerge_OnItemMoved;
    // Merges with the pst files that are located in separate folder.
    pst.MergeWith(Directory.GetFiles(@"D:\test\sources\"));
    Console.WriteLine("Total messages added: {0}", totalAdded);
}
[VB.NET]
totalAdded = 0
Using pst As PersonalStorage = PersonalStorage.FromFile("D:\test\destination.pst")
X

Url: http://www.aspose.com/docs/display/emailnet/Splitting+and+Merging+PST+files

Language: C# | User: Sheraz Khan | Created: Jun 24, 2015 | Tags: Splitting & Merging PST files Split Single PST File into Multiple PSTs Merging of Multiple PSTs into single PST Merging Folders from another PST .NET Email API Microsoft Office Automation