Compact PST after deleting emails


#1

Hi,

I want to find out if Aspose has added functionality to compact PST that we can use after deleting messages. If so, which version of Aspose has it and how do i use it?

I found one of issue where Aspose said they have entered feature request NETWORKNET-33398 back in 2014. But no updates to it i can find online.

Let me know.

Thanks,
Hiren


#2

@hirenp,

I have observed your requirements and like to share that the concerned support is already available in API since Aspose.Email for .NET 17.4. If you remove the message from PST the size shall compact.


#3

I have tried deleting messages from various PST of different sizes, but the size of destination PST remains same as source PST. I don’t see any size reduction. I saw older post where someone requested same, and answer was that enhancement request has been entered, and also DeleteChildItems() has been improved so it permanently deletes messages. But I don’t know status of NETWORKNET-33398. And with latest version of Aspose.Email for .Net, (19.2), i still see same behavior.


#4

@hirenp,

I have observed the issue shared by you and request you to please share the source PST with us around with used sample code. I will be able to verify the issue further on my end on provision of requested information.


#5

Hi Mudassir,

The test pst i used is inside uploaded zip file.

unicode-tmp.zip (2.9 MB)

My sample code i use to delete emails from PST is as follow:

     private void ReducePSTSample()
    {
        string path = @"D:\Temp\unicodepst\unicode-tmp.pst";
        var pstFile = PersonalStorage.FromFile(path);
        var rootFolder = pstFile.RootFolder;
        EnumerateFolder(rootFolder);
        pstFile?.Dispose();
    }
    
    private void EnumerateFolder(FolderInfo folderInfo)
    {
        var beforeDelete = folderInfo.EnumerateMessagesEntryId().ToList();
        if (beforeDelete.Count > 0)
        {
            //delete messages
            folderInfo.DeleteChildItems(beforeDelete);
        }

        if (folderInfo.HasSubFolders)
        {
            foreach (var folder in folderInfo.GetSubFolders(FolderKind.Normal))
            {
                EnumerateFolder(folder);
            }
        }
    }

After running such code to delete all emails in this pst, i look at the file size and it remains same as original file size and its not compacted. If i use outlook to compact it, it goes down to 265 KB.

Let me know if this is a bug or i’m doing something wrong here.


#6

@hirenp,

I have observed the sample code and it does seem to remove the emails but does not reduce the size of storage. It seems to be an issue and we are investigating this on our end. We will get back to you with feedback as soon as the issue will be resolved.


#7

Any update on this issue?


#8

@hirenp,

I have worked with the issue shared by you and it seems to be an issue in API. An issue with ID EMAILNET-39439 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.