由于IMAP实现中的意外数据包格式,握手失败

时间:2017-07-04 14:12:57

标签: c# winforms email imap imapclient

我试图通过c#代码读取我的邮件收件箱并且它发出错误"由于意外的数据包格式而导致握手失败"。

这是我的代码,

   using AE.Net.Mail;
   using System;
   using System.Collections.Generic;
   using System.IO;
   using System.Linq;
   using System.Text;
   using System.Threading.Tasks;

   namespace MailApp
   {
   class Program
   {
     static void Main(string[] args)
     {

         try
         {
             ImapClient ic = new ImapClient("mail.topformtechnologies.com", "username@topformtechnologies.com", "password", AuthMethods.Login, 143, true);

            // Select a mailbox. Case-insensitive
            ic.SelectMailbox("INBOX");
            Console.WriteLine(ic.GetMessageCount());
            Console.ReadLine();
            // Get the first *11* messages. 0 is the first message;
            // and it also includes the 10th message, which is really the eleventh ;)
            // MailMessage represents, well, a message in your mailbox
            MailMessage[] mm = ic.GetMessages(0, 10);
            foreach (MailMessage m in mm)
            {
                Console.WriteLine(m.Body);
                Console.ReadLine();

            }
                ////            SmtpServer.Send(mail);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
            Console.ReadLine();
        }
    }
}

}

以下是详细错误:

System.IO.IOException:由于意外的数据包格式,握手失败。    在System.Net.Security.SslState.StartReadFrame(Byte []缓冲区,Int32 readBytes,AsyncProtocolRequest asyncRequest)    在System.Net.Security.SslState.StartReceiveBlob(Byte []缓冲区,AsyncProtocolRequest asyncRequest)    在System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message,AsyncProtocolRequest asyncRequest)    在System.Net.Security.SslState.StartSendBlob(Byte []传入,Int32计数,AsyncProtocolRequest asyncRequest)    在System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst,Byte [] buffer,AsyncProtocolRequest asyncRequest)    在System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)    在System.Net.Security.SslStream.AuthenticateAsClient(String targetHost,X509CertificateCollection clientCertificates,SslProtocols enabledSslProtocols,Boolean checkCertificateRevocation)    在System.Net.Security.SslStream.AuthenticateAsClient(String targetHost)    在AE:Net.Mail.TextClient.Connect(String hostname,Int32 port,Boolean ssl,RemoteCertificateValidationCallback validateCertificate)中的c:\ Repos \ aenetmail \ TextClient.cs:第87行    在AE:Net.Mail.TextClient.Connect(String hostname,Int32 port,Boolean ssl,Boolean skipSslValidation)c:\ Repos \ aenetmail \ TextClient.cs:第59行    at AE.Net.Mail.ImapClient..ctor(String host,String username,String password,AuthMethods method,Int32 port,Boolean secure,Boolean skipSslValidation)in c:\ Repos \ aenetmail \ ImapClient.cs:line 35    at BulkEmail.CreateSignature.btnFont_Click(Object sender,EventArgs e)位于C:\ Users \ TFTLap2 \ documents \ visual studio 2015 \ Projects \ BulkEmail \ BulkEmail \ CreateSignature.cs:第24行

请有人指导我解决此问题。

提前致谢。

0 个答案:

没有答案