We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adding messages to "Deleted Items" that are not IPM.Note causes exception

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,


Thank you for writing to Aspose support team.

I have tried to reproduce this issue at my end using the latest version of Aspose.Email for .NET 4.2.0 with a sample IPM.Appointment MSG type file. The file is added to the Deleted Folder without any exception. Could you please provide us with a sample MSG file that we can use for our investigation into this issue? We’ll look into it for assisting you further.

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”));<o:p></o:p>

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,


The AddMapiMessageItem is used when a non-IPM.NOTE is initialized using the constructor. In other cases, you can use the AddMessage method. Its good to know that your issue is resolved now. Please feel free to write to us in case you have any other query related to Aspose.Email.