This example demonstrates how to connect to an IMAP server and subsequently download all new mail messages.
Downloading unseen mail messages
CopyC#
using System;
using S22.Imap;
namespace Test {
class Program {
static void Main(string[] args)
{
using (ImapClient client = new ImapClient("imap.gmail.com", 993, "username", "password", AuthMethod.Login, true))
{
// Returns a collection of identifiers of all mails matching the specified search criteria.
IEnumerable<uint> uids = client.Search( SearchCondition.Unseen() );
// Download mail messages from the default mailbox.
IEnumerable<MailMessage> messages = client.GetMessages(uids);
}
}
}
}