This example demonstrates how to connect to an IMAP server using transport-layer encryption (SSL).

Connecting to an IMAP server using SSL

CopyC#
using System;
using S22.Imap;

namespace Test {
    class Program {
        static void Main(string[] args)
        {
            string hostname = "imap.gmail.com",
               username = "myUsername", password = "myPassword";
            // The default port for IMAP over SSL is 993.
            using (ImapClient client = new ImapClient(hostname, 993, username, password, AuthMethod.Login, true))
            {
                Console.WriteLine("We are connected!");
            }
        }
    }
}