Optimized Validation of PST Folder
Aspose.Email for .NET 24.2 lets C# developers enforce container class matching while adding folders to PST files for improved data integrity. The following C# coding sample showcases how to use the newly added EnforceContainerClassMatching
property of the FolderCreationOptions
class for this purpose:
using (var pst = PersonalStorage.Create("storage.pst", FileFormatVersion.Unicode))
{
// Create a standard Contacts folder with the IPF.Contacts container class.
var contacts = pst.CreatePredefinedFolder("Contacts", StandardIpmFolder.Contacts);
// An exception will not arise. EnforceContainerClassMatching is false by default.
contacts.AddSubFolder("Subfolder1", "IPF.Note");
// An exception will occur as the container class of the subfolder being added (IPF.Note)
// does not match the container class of the parent folder (IPF.Contact).
contacts.AddSubFolder("Subfolder3", new FolderCreationOptions {EnforceContainerClassMatching = true, ContainerClass = "IPF.Note"});
}
Source*
Fetch Category Colors from OLM
With this update to the C# Email apps API, users can access category colors associated with Outlook items stored in OLM files. The following C# code examples provide more reference for users.
Here’s how you can get all categories from OLM storage:
using (var olm = OlmStorage.FromFile("storage.olm"))
{
var categories = olm.GetCategories();
foreach (var category in categories)
{
Console.WriteLine($"Category name: {category.Name}");
//Color is represented as a hexadecimal value: #rrggbb
Console.WriteLine($"Category color: {category.Color}");
}
}
Source*
And the following code snippet how to obtain a message category color:
foreach (var msg in olm.EnumerateMessages(folder))
{
if (msg.Categories != null)
{
foreach (var msgCategory in msg.Categories)
{
Console.WriteLine($"Category name: {msgCategory}");
var categoryColor = cat.First(c => c.Name.Equals(msgCategory, StringComparison.OrdinalIgnoreCase)).Color;
Console.WriteLine($"Category color: {categoryColor}");
}
}
}
Source*
Bug Fixes
Several bugs and issues have been addressed in this version of the .NET API, improving stability and the overall user experience.
You can view the list of all new features, enhancements, and bug fixes introduced in this release by visiting Aspose.Email for .NET 24.2 Release Notes.