我试图通过 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[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest) 在 System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) 在 System.Net.Security.SslState。 CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) 在 System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResultlazyResult) 在 System.Net.Security.SslStream.AuthenticateAsClient(String targetHost,
请有人指导我解决这个问题。
提前致谢。