Hi,
Hi Satish,
Thank you for writing to us.
-
At present, there is no method available to reduce the size of the PST file using Aspose API. We already have a new feature request logged as NETWORKNET-33398 in our issue tracking system for achieving this. However, due to other priority tasks, we may not be able to provide this feature in near future.
-
I’m afraid but at present you will have to follow the same procedure as you have mentioned. i.e. extracting items from a source PST, adding a header to each item and then add it to a new PST. You can traverse through all the folders of the source PST and create a new PST with the same structure as shown in the following sample code. In addition, we’ll forward this requirement to our development team for inline modification of information in a PST and share with you if there can be such a feature implemented.
Sample Code:
static void PstToPST()
{
try
{
Console.WriteLine("Loading OST file....");
// load the Outlook OST file
PersonalStorage ost = PersonalStorage.FromFile("OSTStorage.ost");
// get the Display Name of the OST file
Console.WriteLine("Display Name: " + ost.DisplayName);
// get the folders and messages information
FolderInfo folderInfo = ost.RootFolder;
PersonalStorage NewPst = PersonalStorage.Create("Output.pst", FileFormatVersion.Unicode);
// Add and Get the folder info
FolderInfo NewFolderInfo = NewPst.RootFolder.AddSubFolder(folderInfo.DisplayName);
// call the recursive method to extract msg files from each folder
ExtractMsgFiles(folderInfo, ost, NewPst, NewFolderInfo);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
static void ExtractMsgFiles(FolderInfo folderInfo, PersonalStorage ost, PersonalStorage NewPst, FolderInfo NewFolderInfo)
{
// display the folder name
Console.WriteLine("Folder: " + folderInfo.DisplayName);
Console.WriteLine("==================================");
// loop through all the messages in this folder
MessageInfoCollection messageInfoCollection = folderInfo.GetContents();
foreach (MessageInfo messageInfo in messageInfoCollection)
{
// get the message in MapiMessage instance
MapiMessage message = ost.ExtractMessage(messageInfo);
try
{
//add new header before adding message to destination pst
NewFolderInfo.AddMessage(message);
}
catch (Exception ex)
{
Console.WriteLine("Folder: " + folderInfo.DisplayName);
Console.WriteLine("Saving message {0} ....", messageInfo.Subject);
Console.WriteLine(ex.Message);
}
}
// call this method recursively for each subfolder
if (folderInfo.HasSubFolders == true)
{
foreach (FolderInfo subfolderInfo in folderInfo.GetSubFolders())
{
FolderInfo RecNewFolderInfo = NewFolderInfo.AddSubFolder(subfolderInfo.DisplayName);
ExtractMsgFiles(subfolderInfo, ost, NewPst, RecNewFolderInfo);
}
}
}
Hi Kashif,
Hi Satish,
Hi Satish,
I am Outlook user. I have large numbers of PST files due to which I am facing problems while accessing data . I want to reduce PST file size . Is any possible way is there by which I can make separate folder and put all previous and older PST files there ?