Hi there,
I have the following code:
// Create a test PST
PersonalStorage pst = PersonalStorage.Create("…\…\Data\out.pst", FileFormatVersion.Unicode);
// Get the Deleted Items folder
FolderInfo fiDeletedItems = pst.GetPredefinedFolder(StandardIpmFolder.DeletedItems);
// We are getting NotSupportedException exception with the message “MessageClass of the item to be added isn’t supported"
fiDeletedItems.AddMapiMessageItem(MapiMessage.FromFile(”…\…\Data\IPM.Note.CustomClass.msg"));
// Let’s try the Inbox instead
FolderInfo fiInbox = pst.CreatePredefinedFolder(“Inbox”, StandardIpmFolder.Inbox);
// Everything is OK
fiInbox.AddMapiMessageItem(MapiMessage.FromFile("…\…\Data\IPM.Note.CustomClass.msg"));
Essentially, I am unable to add items of IPM.Note.* into the Deleted Items folder. Is this by design?
Hi Sevag,
I have provided two sample messages of items that cannot be added to the Deleted Items folder.
Additionally, I found that the same issue (unsupported message class) also affects the Root folder. Here’s more sample code to show that:
// Create the PST
PersonalStorage pst = PersonalStorage.Create(@“C:\temp\aspose\MsgClass\out.pst”, FileFormatVersion.Unicode);
// Create pointers to PST folders
FolderInfo fiDeletedItems = pst.GetPredefinedFolder(StandardIpmFolder.DeletedItems);
FolderInfo fiInbox = pst.CreatePredefinedFolder(“Inbox”, StandardIpmFolder.Inbox);
FolderInfo fiRoot = pst.RootFolder;
// Add to root folder:
// We are getting NotSupportedException exception with the message "MessageClass of the item to be added doesn’t supported"
try
{
fiRoot.AddMapiMessageItem(MapiMessage.FromFile(@“C:\temp\aspose\MsgClass\Sample.msg”));
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
try
{
// Add to deleted items folder:
// We are getting NotSupportedException exception with the message “MessageClass of the item to be added doesn’t supported”
fiDeletedItems.AddMapiMessageItem(MapiMessage.FromFile(@“C:\temp\aspose\MsgClass\Sample.msg”));
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
// This works:
fiInbox.AddMapiMessageItem(MapiMessage.FromFile(@“C:\temp\aspose\MsgClass\Sample.msg”));
Hi Sevag,
Please try adding the message to Deleted Items folder using the AddMessage that will work with both the messages you have shared. Let us know your feedback then.
fiDeletedItems.AddMessage(MapiMessage.FromFile(dir+“Sample.msg”));
Thank you, this works and it also does not change the message class of the items. Other MAPI properties are preserved as well.
Is it “best practice” then to just use AddMessage instead of AddMAPIMessage? I thought that AddMessage would essentially be something like EML, but apparently that is incorrect.
Thanks for your time and assistance.
Hi Sevag,