2

i try to connect with a mailserver with Mailkit, but its loading on the ImapClient.connect like forever. I got no reaction, no error and no log.

I use .NET Framework 4.5.1 c# Visualstudio. I createt a simple form with textboxes and a button. The connection host is imap.1und1.de with Port 993 and SSL true. Changing the Host make no other result. It got stuck in the Line: client.Connect("imap.1und1.de", 993, true);.

Following the sourcecode for the test.

 private void Login()
    {
        try
        {
            using (var client = new ImapClient(new ProtocolLogger(Console.OpenStandardOutput())))
            {
                // For demo-purposes, accept all SSL certificates
                client.ServerCertificateValidationCallback = (s, c, ch, e) => true;

                client.Connect("imap.1und1.de", 993, true);
                Console.Write("Connect done");
                client.Authenticate(txtLoginName.Text, txtLoginPassword.Text);

                // The Inbox folder is always available on all IMAP servers...
                var inbox = client.Inbox;
                inbox.Open(FolderAccess.ReadOnly);

                Console.WriteLine("Total messages: {0}", inbox.Count);
                Console.WriteLine("Recent messages: {0}", inbox.Recent);

                for (int i = 0; i < inbox.Count; i++)
                {
                    var message = inbox.GetMessage(i);
                    Console.WriteLine("Subject: {0}", message.Subject);
                }

                client.Disconnect(true);
            }

        }
        catch (Exception ex)
        {

            MessageBox.Show(ex.Message);
        }
    }

1 Answers1

3

There seems to be a bug in the latest version of MailKit (2.1.0.2), downgrade to 2.1.0.1 and it should work.

Mikael Gyth
  • 427
  • 3
  • 16