代码:
using (var client = new ImapClient(new ProtocolLogger("logImap.txt")))
{
// For demo-purposes, accept all SSL certificates
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("imap.yandex.ru", 993, true);
client.Authenticate(login, password);
// 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);
}
堆栈跟踪:
MailKit.Net.Imap.ImapEngine.AssertToken(MailKit.Net.Imap.ImapToken, MailKit.Net.Imap.ImapTokenType, string, object[]) MailKit.Net.Imap.ImapEngine.ConnectAsync(MailKit.Net.Imap.ImapStream, bool, System.Threading.CancellationToken) System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading .Tasks.Task) System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() MailKit.Net.Imap.ImapClient.ConnectAsync(string, int, MailKit.Security.SecureSocketOptions, bool, System.Threading.CancellationToken) System.Runtime。 ExceptionServices.ExceptionDispatchInfo。Throw() System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task) System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task) ...
和 logImap.txt:
Connected to imaps://imap.yandex.ru:993/
S: OK IMAP4
我能解决这个问题吗?