I'm trying to read an email from my mailbox using the MailKit library. Unfortunately the program throws this MailKit.Security.AuthenticationException: 'LOGIN failed.'
The credentials match (I tried to log in through the browser)
I'm trying to read an email from my mailbox using the MailKit library. Unfortunately the program throws this
MailKit.Security.AuthenticationException: 'LOGIN failed.'
I would be grateful for any help, I don't know what to do. I googled, tried this
client.Connect("imap.outlook.com", 993, SecureSocketOptions.None);
But nothing came up when I changed
SecureSocketOptions
to
Auto
the same exception was thrown
My code:
using (var client = new ImapClient())
{
using (var cancel = new CancellationTokenSource())
{
client.Connect("imap.outlook.com", 993, true);
client.Authenticate("mail@test.cz", "password", cancel.Token);
var inbox = client.Inbox;
inbox.Open(FolderAccess.ReadOnly, cancel.Token);
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, cancel.Token);
Console.WriteLine("Subject: {0}", message.Subject);
}
var query = SearchQuery.DeliveredAfter(DateTime.Parse("2013-01-12"))
.And(SearchQuery.SubjectContains("MailKit"))
.And(SearchQuery.Seen);
foreach (var uid in inbox.Search(query, cancel.Token))
{
var message = inbox.GetMessage(uid, cancel.Token);
Console.WriteLine("[match] {0}: {1}", uid, message.Subject);
}
client.Disconnect(true, cancel.Token);
}
}
What I have tried:
Checked the credentials in Browser, switched Options in Client