MailKitusing System;
using MailKit.Net.Imap;
using MailKit;
namespace MailKit_app
{
class Program
{
static void Main(string[] args)
{
using (var client = new ImapClient())
{
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
client.Connect("imap.yandex.ru", 993, true);
client.Authenticate("login@yandex.ru", "password");
var junk = client.GetFolder(SpecialFolder.Junk);
junk.Open(FolderAccess.ReadOnly);
Console.WriteLine("Total messages: {0}", junk.Count);
Console.WriteLine("Recent messages: {0}", junk.Recent);
for (int i = 0; i < junk.Count; i++)
{
var message = junk.GetMessage(i);
Console.WriteLine("Subject: {0}", message.Subject);
}
client.Disconnect(true);
}
}
}
}