Email Client Threads

Message Threads

This tutorial is about manipulating message threads using Aspose.Email Cloud build-in client.

Using threads, you can easily structure emails in the mailbox. Instead of working with an unstructured list of messages, it is better to work and analyze only certain threads of emails. In the picture below you can see how the messages are arranged in threads:

todo:image_alt_text

Built-In Email Client

Aspose.Email Cloud API provides a built-in email client with a unified API, which supports different account types like SMTP, POP3, IMAP, EWS.

Threads support by protocols:

  • Exchange Web Services (EWS) Accounts: native support, no extra configuration needed. Exchange Web Services is an alternative to the MAPI protocol. EWS is used by the latest version of Microsoft Outlook for Mac and Microsoft Entourage for Mac.
  • POP3: thread support is implemented using message cache. Message cache location on storage should be specified. The Post Office Protocol allows manipulating the user’s client application with a mailbox supported on a mail server.
  • IMAP: thread support is implemented using message cache, at the moment. Native threads support will be implemented in a future version. The Internet Message Access Protocol is the Internet protocol that allows an email client to access emails on a remote mail server.
  • WebDav: threads are not supported.
  • Virtual Multi-account: gets threads from underlying accounts and provides them as is.

Thread Support using Message Cache

Aspose.Email Cloud built-in email client supports native threads for EWS and IMAP accounts. For POP3 accounts we provide this functionality using our own threads implementation. This implementation uses messages’ cache, located on Aspose Storage and our own threads algorithm, which generates threads based on message subject and participants.

Message cache is also used for IMAP accounts if the IMAP server does not provide native threads.

To support threads using cache, you should provide cache location during email account setup:

Setup account with cache file

The account.cache file contains basic information about messages and threads (folder, subject, message identifiers, dates and participants).

Get List of Threads

To get the list of threads for a given folder (folder parameter is ignored for POP3 accounts), use GetList method from ClientThreadApi:

Set parameter updateFolderCache to false if you don’t need to sync threads cache with your email account.

Fetch Thread Messages

GetList method returns all email threads from the folder. All threads contain a lists of messages. However, these messages contain only basic information: MessageId, Date, Subject, Participants (From, To, CC). Use GetMessages method from ClientThreadApi if you need to fetch full messages for a thread, including message bodies, attachments, alternate views, etc.

Some native thread implementations (such as EWS conversations) require folder argument. However, you can set this parameter to null if cached threads used (the thread’s folder is already stored in the cache).

Mark All Thread Messages as Read or Unread

The SetIsReadFlag method from ClientThreadApi should be used to mark all thread messages as (un)read.

Some native thread implementations (such as EWS conversations) require folder argument. However, you can set this parameter to null if cached threads used (the thread’s folder is already stored in the cache).

Mark thread as read

Delete Thread

You can delete the thread and all corresponding messages using Delete method from ClientThreadApi.

Some native thread implementations (such as EWS conversations) require folder argument. However, you can set this parameter to null if cached threads used (the thread’s folder is already stored in the cache).

Move Thread to Another Folder

All thread messages can be moved from one folder to another using one single request of Move method from ClientThreadApi (POP3 is not supported):

More Tutorials

See more Aspose Email tutorials: