0 votes

I want to read one by one mail in the Gmail threads.
How can I do this using Mail.dll

by

1 Answer

0 votes

When you download message info, Gmail provides a thread ID (X-GM-THRID attribute in FETCH command response):

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.gmail.com");
    imap.UseBestLogin("pat@gmail.com", "password");

    imap.SelectInbox();

    List<long> uids = imap.GetAll();
    List<messageInfo> infos = imap.GetMessageInfoByUID(uids);

    foreach (MessageInfo info in infos)
    {
        Console.WriteLine("{0} - {1}",
            info.Envelope.GmailThreadId,
            info.Envelope.Subject);
    }

    imap.Close();
}

You can also search for all emails in the specific thread:

List<long> uids = imap.Search().Where(
        Expression.GmailThreadId(threadId));
by (301k points)
...