Browse our Products

Aspose.Email for CPP 26.8 Release Notes

Aspose.Email for C++ 26.8 is based on Aspose.Email for .NET 26.7.

Aspose.Email for C++ does not support asyncronic features of e-mail protocols

New Features

Add Methods Now Return the Newly Created Instance

The Add methods for both recipients and attachments have been updated to return the object they create, allowing immediate access to the new item without a separate lookup. This streamlines code that needs to configure the newly added recipient or attachment right after insertion.

Public API Changes:

  • System::SharedPtr MapiAttachmentCollection::Add(System::String name, System::SharedPtr msg) — Returns newly created attachment
  • System::SharedPtr MapiAttachmentCollection::Add(System::String name, System::ArrayPtrSystem::Byte data) – Returns newly created attachment
  • System::SharedPtr Add(System::String name, System::SharedPtr options) - Returns newly created attachment
  • System::SharedPtr MapiRecipientCollection::Add(System::String address, System::String displayName, MapiRecipientType recipientType) - Returns newly created recipient
  • System::SharedPtr<MapiRecipient> MapiRecipientCollection::Add(System::String address, System::String addressType, System::String displayName, MapiRecipientType recipientType) 6 Returns newly created recipient

Code Example:

auto message = System::MakeObject<MapiMessage>();

// Add recipient
System::SharedPtr<MapiRecipient> recipient = message->get_Recipients()->Add(u"alice.johnson@example.com", u"SMTP", u"Alice Johnson", Aspose::Email::Mapi::MapiRecipientType::MAPI_TO);
recipient->set_DisplayName(u"Alice Johnson");

// Add attachment from file bytes
System::ArrayPtr<uint8_t> fileBytes = System::IO::File::ReadAllBytes(u"invoice.pdf");
System::SharedPtr<MapiAttachment> attachment = message->get_Attachments()->Add(u"invoice.pdf", fileBytes);
attachment->set_DisplayName(u"Invoice #2026-001.pdf");

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