Rebex POP3

POP3, 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 POP3 session goes through the following steps:

Downloading emails using POP3 

The following code downloads all emails:

// create POP3 client instance
using (var pop3 = new Rebex.Net.Pop3())
{
    // connect to Gmail POP3 server
    pop3.Connect("pop.gmail.com", SslMode.Implicit);

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

    // get message list
    Pop3MessageCollection list = pop3.GetMessageList();

    // print some info
    Console.WriteLine("{0} email(s) found.", list.Count);

    // download all messages
    foreach (Pop3MessageInfo info in list)
    {
        MailMessage mail = pop3.GetMailMessage(info.SequenceNumber);

        // do something with the mail
        // ...
    }

    // disconnect (required to commit delete operations)
    pop3.Disconnect();
}
' create POP3 client instance
Using pop3 = New Rebex.Net.Pop3()
    ' connect to Gmail POP3 server
    pop3.Connect("pop.gmail.com", SslMode.Implicit)

    ' authenticate
    pop3.Login(username, password)

    ' get message list
    Dim list As Pop3MessageCollection = pop3.GetMessageList()

    ' print some info
    Console.WriteLine("{0} email(s) found.", list.Count)

    ' download all messages
    For Each info As Pop3MessageInfo In list

        ' do something with the mail
        ' ...
        Dim mail As MailMessage = pop3.GetMailMessage(info.SequenceNumber)
    Next

    ' disconnect (required to commit delete operations)
    pop3.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...