Pst Extraction Failure


#1

When Extracting messages from the following PST an exception is thrown

I used the following code:

    string fileName = @"/tmp/native-pst-extraction-contact-failure.pst";

    ExtractPst(fileName);

    public static void ExtractPst(string pstfilename)
    {
        Program.InitializeAsposeMailLicense();
        string path = pstfilename;

        // Save message to MemoryStream
        using (PersonalStorage personalStorage = PersonalStorage.FromFile(path))
        {
            List<string> allMessageIds = GetAllMessageId(personalStorage.RootFolder);

            foreach (string entryIdString in allMessageIds)
            {
                using (MemoryStream memorystream = new MemoryStream())
                {
                    Console.WriteLine("Saving {0} at {1}", entryIdString, DateTime.Now);
                    personalStorage.SaveMessageToStream(entryIdString, memorystream);
                    Console.WriteLine("Saved {0} at {1}", entryIdString, DateTime.Now);
                }
            }
            
        }

    }

    static List<string> GetAllMessageId(FolderInfo folder)
    {
        List<string> messageIdList = new List<string>();

        var messageIds = folder.EnumerateMessagesEntryId();

        messageIdList.AddRange(messageIds.ToList());

        var subFolders = folder.EnumerateFolders();
        foreach (var subFolder in subFolders)
        {
            var someMessageIds = GetAllMessageId(subFolder);
            messageIdList.AddRange(someMessageIds);
        }

        return messageIdList;
    }

#2

@russ.nichols,

I have worked with source file shared by you. The code snippet you have shared includes some undeclared variables so would you please share your SSCCE code reproducing the issue so that we may try to reproduce and investigate it in our environment.


#3

Please see the code and exception I observe when running the code

using Aspose.Email.Storage.Pst;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace PstTester
{
class Program
{

    static void Main(string[] args)
    {
        string fileName = @"/tmp/native-pst-extraction-contact-failure.pst";
        ExtractPst(fileName);
    }

    public static void ExtractPst(string pstfilename)
    {
        string path = pstfilename;

        // Save message to MemoryStream
        using (PersonalStorage personalStorage = PersonalStorage.FromFile(path))
        {
            List<string> allMessageIds = GetAllMessageId(personalStorage.RootFolder);

            foreach (string entryIdString in allMessageIds)
            {
                using (MemoryStream memorystream = new MemoryStream())
                {
                    Console.WriteLine("Saving {0} at {1}", entryIdString, DateTime.Now);
                    personalStorage.SaveMessageToStream(entryIdString, memorystream);
                    Console.WriteLine("Saved {0} at {1}", entryIdString, DateTime.Now);
                }
            }

        }

    }

    static List<string> GetAllMessageId(FolderInfo folder)
    {
        List<string> messageIdList = new List<string>();

        var messageIds = folder.EnumerateMessagesEntryId();

        messageIdList.AddRange(messageIds.ToList());

        var subFolders = folder.EnumerateFolders();
        foreach (var subFolder in subFolders)
        {
            var someMessageIds = GetAllMessageId(subFolder);
            messageIdList.AddRange(someMessageIds);
        }

        return messageIdList;
    }

}

}

Saving AAAAAP7AHGmBWeJPsIrlstGRS5TE1iEA at 4/12/2019 9:05:19 PM

nhandled Exception: System.OverflowException: Arithmetic operation resulted in an overflow.
at #=zuUx7So8qlEyLEkffT$rwUA_MOT3MU7XEYQ==.#=zHIkGoppaRxwa(Byte[] #=zbmX3aCg=, Int32 #=zWRChgFM=)
at #=zuUx7So8qlEyLEkffT$rwUA_MOT3MU7XEYQ==.#=zXyCHhwvgaxfr(Int64 #=zJmbxurc=, Byte[] #=zbmX3aCg=)
at #=z72k7a$mdzj3v_55eqYKXq2yV4hRs7EwypYnyW_s=.#=z5O6RE5nknLRF(UInt32 #=zA936i6zVftzP, Stream #=zVhu4sBU=)
at Aspose.Email.Storage.Pst.PersonalStorage.SaveMessageToStream(String entryId, Stream stream)
at PstTester.Program.ExtractPst(String pstfilename) in C:\Users\Administrator\Documents\GitHub\disco-batch\tools\PstTester\PstTester\Program.cs:line 32
at PstTester.Program.Main(String[] args) in C:\Users\Administrator\Documents\GitHub\disco-batch\tools\PstTester\PstTester\Program.cs:line 15


#4

@russ.nichols,

I have observed the issue shared by you and an issue with ID EMAILNET-39450 has been created in our issue tracking system to investigate and resolve the issue. This thread has been linked with issue so that you may be notified once issue will be fixed.