+1 vote
using Lesnikowski.Client.IMAP;
using Lesnikowski.Mail;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            using (Imap imap = new Imap())
            {
                imap.Connect("imap.gmail.com");
                imap.Login("junaid21700@gmail.com","xxx");

                imap.SelectInbox();

                //....

                imap.Close(true);
            }
            Console.ReadLine();

        }
    }
by
Full listing that download unseen emails from Gmail using the latest version is available here:
https://www.limilabs.com/blog/download-emails-from-gmail

1 Answer

0 votes

1.
You are using very old version of the Mail.dll.

Please update it to the latest version:
https://www.limilabs.com/mail/download

2.
Gmail server is not listening on the non-SSL port. You need to use SSL when you connect to Gmail:

imap.ConnectSSL("imap.gmail.com");
by (301k points)
...