Rebex IMAP

IMAP, SMTP, MIME, S/MIME libraries for .NET

Download 30-day free trial Buy from $199
More .NET libraries

Back to feature list...

Easy-to-use API

A typical IMAP session goes through the following steps:

Getting list of unread emails using IMAP 

The following code finds all unread e-mail messages and prints information about each of them:

// create IMAP client instance
using (var imap = new Rebex.Net.Imap())
{
    // connect to Gmail IMAP server
    imap.Connect("imap.gmail.com", SslMode.Implicit);

    // authenticate
    imap.Login(username, password);

    // select folder to work with
    imap.SelectFolder("INBOX");

    // get list of unread messages
    ImapMessageCollection list = imap.Search(ImapSearchParameter.Unread);

    // print some info
    foreach (ImapMessageInfo info in list)
    {
        Console.WriteLine("From: {0}", info.From);
        Console.WriteLine("To: {0}", info.To);
        Console.WriteLine("Subject: {0}", info.Subject);
    }

    // disconnect (not required, but polite)
    imap.Disconnect();
}
' create IMAP client instance
Using imap = New Rebex.Net.Imap()
    ' connect to Gmail IMAP server
    imap.Connect("imap.gmail.com", SslMode.Implicit)

    ' authenticate
    imap.Login(username, password)

    ' select folder to work with
    imap.SelectFolder("INBOX")

    ' get list of unread messages
    Dim list As ImapMessageCollection = imap.Search(ImapSearchParameter.Unread)

    ' print some info
    For Each info As ImapMessageInfo In list
        Console.WriteLine("From: {0}", info.From)
        Console.WriteLine("To: {0}", info.To)
        Console.WriteLine("Subject: {0}", info.Subject)
    Next

    ' disconnect (not required, but polite)
    imap.Disconnect()
End Using

Note: Although implicit SSL mode has been discouraged since 1999 (see RFC 2595) Gmail and some other providers still only supports this mode. Explicit mode should be used instead when available.

Back to feature list...