Browse our Products

Aspose.Email for CPP 22.1 Release Notes

Aspose.Email for C++ 22.1 is based on Aspose.Email for .NET 21.12.

New Features

OLM file traversal API

The traversal API allows extracting all items as far as possible, without throwing out exceptions, even if some data of the original file is corrupted.

The following steps show how to use this API.

Use OlmStorage(TraversalExceptionsCallback callback) constructor and Load(String fileName) method instead of FromFile method.

The constructor allows defining a callback method.

TraversalExceptionsCallback callback = std::function<void(TraversalAsposeException exception, System::String id)>>([_lch_exceptionsCount, &exceptionsCount](TraversalAsposeException exception, System::String id) -> void
{
/* Exception handling  code. */
}

System::SharedPtr<OlmStorage> storage = System::MakeObject<OlmStorage>(callback);

Loading and traversal exceptions will be available through the callback method.

The Load method returns 'true' if the file has been loaded successfully and further traversal is possible. If a file is corrupted and no traversal is possible, 'false' is returned.

if (olm->Load(fileName))

Code example


TraversalExceptionsCallback callback =
    std::function<void(TraversalAsposeException exception, System::String id)>>([&](TraversalAsposeException exception, System::String id) -> void
    {
    /* Exception handling  code. */
    }

System::SharedPtr<OlmStorage> storage = System::MakeObject<OlmStorage>(callback);

if (storage->Load(fileName))
{
    auto folderHierarchy = olm->GetFolders();
    ExtractItems(olm, folderHierarchy);
}

void ExtractItems(System::SharedPtr<Aspose::Email::Storage::Olm::OlmStorage> storage, System::SharedPtr<System::Collections::Generic::ListExt<System::SharedPtr<Aspose::Email::Storage::Olm::OlmFolder>>> folders)
{
    for (auto&& folder : System::IterateOver(folders))
    {
        if (folder->get_HasMessages())
        {
            Console::WriteLine(folder);

            int32_t count = 0;

            for (auto&& msg : System::IterateOver(storage->EnumerateMessages(folder)))
            {
                Console::WriteLine(msg->get_Subject());
            }
        }

        if (folder->get_SubFolders()->get_Count() > 0)
        {
            ExtractItems(storage, folder->get_SubFolders());
        }
    }
}

Export calendar and contact items from Zimbra backup files

We have implemented the export of Zimbra’s calendar and contacts to iCalendar and VCard formats.

Code example


auto reader = System::MakeObject<TgzReader>(u"test2.tgz");
reader->ExportTo(u"out");

The full code of the examples can be found at Aspose Email for C++ GitHub examples repository.