Browse our Products
Aspose.Email for CPP 20.5 Release Notes
Aspose.Email for C++ 20.5 is based on Aspose.Email for .NET 20.5.
New Features
Email Threading Using ImapClient
Email threading is a useful feature that allows to organize emails into conversations in a hierarchical manner. It is possible by grouping all forwards, replies, and reply-all messages related to the same conversation together. Basically, the IMAP protocol may support the THREAD capability defined in RFC-5256. Besides, there is another IMAP extension provided by Gmail and described as X-GM-EXT-1.
We have added a GetMessageThreads method for receiving message threads by ImapClient.
SharedPtr<List<SharedPtr<MessageThreadResult>>> GetMessageThreads(SharedPtr<BaseSearchConditions> conditions);
Also, the following properties have been added to check the extensions available for the current IMAP server.
bool get_GmExt1Supported(); // Gets information whether Gmail X-GM-EXT-1 extension is supported
bool get_ThreadSupported(); // Gets information whether THREAD extension is supported
System::ArrayPtr<System::String> get_ThreadAlgorithms(); // Gets supported THREAD algorithms
Note, if you’re working with Gmail, it likely supports X-GM-EXT-1.
The following code samples show the usage of email threading features. Let’s say we need to get the email threads from Gmail.
void PrintConversaton(String indent, SharedPtr<List<SharedPtr<MessageThreadResult>>> conversation, SharedPtr<List<SharedPtr<ImapMessageInfo>>> messages)
{
for (auto thread : IterateOver(conversation))
{
System::String subject;
for (auto message : IterateOver(messages))
{
if (message->get_UniqueId() == thread->get_UniqueId())
{
subject = message->get_Subject();
break;
}
}
System::Console::WriteLine(u"{0} ({1}) {2}", indent, thread->get_UniqueId(), subject);
if (thread->get_ChildMessages()->get_Count() != 0)
{
PrintConversaton(indent += u"-", thread->get_ChildMessages(), messages);
}
}
}
void IMAPEmailThreading()
{
System::SharedPtr<ImapClient> client = System::MakeObject<ImapClient>(u"imap.gmail.com", 993, u"username", u"password", Aspose::Email::Clients::SecurityOptions::SSLImplicit);
client->SelectFolder(ImapFolderInfo::InBox);
// get a list of messages that we'll group by conversation
System::SharedPtr<ImapMessageInfoCollection> messages = client->ListMessages();
// make sure the IMAP server supports X-GM-EXT-1 extension
if (client->get_GmExt1Supported())
{
for (auto message : IterateOver(messages))
{
String conversationId = message->get_ConversationId();
if (String::IsNullOrEmpty(conversationId))
{
continue;
}
// create the necessary search conditions for a thread
auto conditions = MakeObject<XGMThreadSearchConditions>();
conditions->set_ConversationId(conversationId);
conditions->set_UseUId(true);
// get results
System::SharedPtr<List<SharedPtr<MessageThreadResult>>> conversation = client->GetMessageThreads(conditions);
// print the email conversation in hierarchically manner
PrintConversaton(u"", conversation, ImapMessageInfoCollection::to_List(messages));
System::Console::WriteLine(System::String(u'-', 20));
}
}
}
The full code of the example can be found at Aspose Email for C++ GitHub examples repository
Features Not Implemented
The following features are not implemented in Aspose.Email for C++ 20.5 but they are implemented in Aspose.Email for .NET 20.5:
- Microsoft Graph REST API v1.0
API Resources
The following API resources can be of help to you in getting started with Aspose.Email API.
- Product Documentation – Provides detailed examples of working with the API
- API Reference Guide – Details all the namespaces and classes of the API
- GitHub Examples – Provides ready to run API example
- Support Forum – Write to us if you have any query or inquiry about the API