We are using the Aspose.Email product for .Net to create PST files and insert MSG files into them. This is the code we are using:
private List WriteToFolder(List mapiMessageItems, string folderPath, string pathToPstFile)
{
PersonalStorage _personalStorage = PersonalStorage.Create(pathToPstFile, FileFormatVersion.Unicode);
if (string.IsNullOrEmpty(folderPath))
{
return _personalStorage.RootFolder;
}
string[] folders = folderPath.Split(new[] { Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
FolderInfo folderInfo = null;
FolderInfo parentFolder = _personalStorage.RootFolder;
for (int i = 0; i < folders.Length; i++)
{
string fldName = folders[i];
var existsFolder = parentFolder.GetSubFolder(fldName);
if (existsFolder == null)
{
FolderInfo folderInfo = null;
string key = StandardIpmFolders.Keys.FirstOrDefault(x => string.Compare(x, fldName, StringComparison.OrdinalIgnoreCase) == 0);
if (!string.IsNullOrEmpty(key) && currentFolder == _personalStorage.RootFolder)
{
folderInfo = _personalStorage.CreatePredefinedFolder(fldName, StandardIpmFolders[key]);
}
else if (currentFolder != null)
{
folderInfo = currentFolder.AddSubFolder(fldName);
}
parentFolder = folderInfo;
}
else
{
parentFolder = existsFolder;
}
if (i == folders.Length - 1 && folderInfo == null)
{
folderInfo = parentFolder;
}
}
IEnumerable mapiMessages = mapiMessageItems.Select(i => i.Message).ToList();
try
{
folderInfo.AddMessages(mapiMessages);
return mapiMessageItems;
}
catch (Exception ex)
{
Logger.Error("Failed to add multiple items to PST! Exception: " + ex);
throw;
}
}
//-----------------Class MapiMessageItem has the following public properties---------------------//
public class MapiMessageItem : Item
{
///
/// Message content
///
public MapiMessage Message { get; set; }
///
/// Used for Envelope reconstructor and verification (only P2 should be verified)
///
public MapiMessage P2 { get; set; }
}
Version 15.0.4667.1000
**Beginning NDB recovery
**Attempting to open database
**Attempting to validate header
**Attempting to validate AMap
**Attempting to validate BBT
**Attempting to validate NBT
**Attempting to validate BBT refcounts
**Attempting to validate header NID high-water marks
**Beginning PST/OST recovery
**Attempting to recover all top-level objects
**Store created by build: (not available)
!!Search folder (nid=EC1) missing update queue
!!Missing the outgoing queue
!!Missing template (nid=6B6)
!!Missing template (nid=6D7)
!!Missing template (nid=6F8)
!!HMP not found - creating
**Attempting to walk all folders
!!Attachment (nid=8045) missing or invalid PR_ATTACH_SIZE
!!Attachment table for 200064, row doesn’t match sub-object:
irow = 0, RowID = 8045
!!Contents Table for 8022, row doesn’t match sub-object:
irow = 2, RowID = 200064
!!Attachment (nid=8025) missing or invalid PR_ATTACH_SIZE
!!Attachment table for 200044, row doesn’t match sub-object:
irow = 0, RowID = 8025
!!Contents Table for 8022, row doesn’t match sub-object:
irow = 1, RowID = 200044
**Attempting to locate any orphaned folders/messages
**Performing final HMP validation
**Attempting to check top-level objects for consistency
??Deleting SDO
**Updating folder hierarchy
We are sending these PST files to another vendor for ingestion, and their ingestion tool is failing to ingest most of these files. Our project is in a seriously bad situation, so i request that this be prioritized and resolved as quickly as possible.
We have been able to reproduce this issue with the last three releases of Aspose.Email, including 6.2.
Please advise.