Browse our Products

Aspose.Email for .NET 20.5 Release Notes

All Changes

EMAILNET-39781Add support for message threadsFeature
EMAILNET-39710Calendar Item failing to get added in Office365 account calendarEnhancement
EMAILNET-39794Set Timezone is not visible in MS Outlook 2016Enhancement
EMAILNET-39806IEWSClient: Get folder info by pathEnhancement
EMAILNET-39823Can’t save MailMessage with default DateBug
EMAILNET-39705Meeting opened as appointment in saved PST when viewed in MS OutlookBug
EMAILNET-39803Office 365 Recurrence ICS not getting AppendedBug
EMAILNET-39811Extra symbols are in the message bodyBug
EMAILNET-39812Memory issue loading MapiMessageBug
EMAILNET-39814Invalid cast exception in constructor Aspose.Email.Clients.Smtp.SmtpClientBug
EMAILNET-39815Querymessages not working properly for ListMessagesBug
EMAILNET-39818MSG to MHTML wrong sent time extractedBug
EMAILNET-39820Aspose.Email: there are unclosed tags in the HtmlBody after loading an .msg fileBug
EMAILNET-39821Erroneous meeting end times on recurring meetingsBug
EMAILNET-39816Parsing Appointment resulting recurrency error rule errorBug

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.

 GetMessageThreads(BaseSearchConditions conditions)

Also, the following properties have been added to check the extensions available for the current IMAP server.

 bool GmExt1Supported // Gets information whether Gmail X-GM-EXT-1 extension is supported

bool ThreadSupported // Gets information whether THREAD extension is supported

string[] 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.

 using (ImapClient client = new ImapClient("", 993, "username", "password", SecurityOptions.SSLImplicit))



    // get a list of messages that we'll group by conversation

    var messages = client.ListMessages();

    // make sure the IMAP server supports X-GM-EXT-1 extension

    if (client.GmExt1Supported)


        foreach (var conversationId in messages

            // this query just gets unique conversationId for our example

            .Select(message => message.ConversationId)

            .Where(conversationId => !string.IsNullOrEmpty(conversationId)).Distinct())


            // create the necessary search conditions for a thread

            var conditions = new XGMThreadSearchConditions


                ConversationId = conversationId,

                UseUId = true


            // get results

            List<MessageThreadResult> conversation = client.GetMessageThreads(conditions);

            // print the email conversation in hierarchically manner

            PrintConversaton(string.Empty, conversation, messages);

            Console.WriteLine(new string('-', 20));




/// <summary>

/// Prints the email conversation in hierarchically manner

/// </summary>

public static void PrintConversaton(string indent, List<MessageThreadResult> conversation, List<ImapMessageInfo> messages)


    foreach (var thread in conversation)


        Console.WriteLine("{0} ({1}) {2}", indent, thread.UniqueId,

            messages.Find(x => x.UniqueId == thread.UniqueId).Subject);

        if (thread.ChildMessages.Count != 0)


            PrintConversaton(indent += "-", thread.ChildMessages, messages);




The code will slightly change if the IMAP server supports THREAD capability:

  1. Check if the IMAP server supports THREAD extension:

 if (client.ThreadSupported)
  1. Сreate the suitable search conditions for a thread:

 var conditions = new ThreadSearchConditions


    Algorithm = client.ThreadAlgorithms[0],

    UseUId = true