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;
}