POP3 Client in C# and VB.NET

The Post Office Protocol (POP) was the first widely used protocol for receiving mail messages.

GemBox.Email enables you to work with the POP protocol in C# and VB.NET using a PopClient class. It supports the latest version (version 3; POP3) defined in RFC 1939. To learn about how to receive an email and how to connect with some common POP3 servers (like Gmail, Outlook, Yahoo, etc.), visit our Receive example.

The following example shows how to create a new PopClient and use it to connect to, authenticate and disconnect from a remote POP3 server.

Screenshot of PopClient's output
Using a POP3 client in C# and VB.NET
using System;
using GemBox.Email;
using GemBox.Email.Pop;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        // Create new POP client.
        using (var pop = new PopClient("<ADDRESS> (e.g. pop.gmail.com)"))
        {
            // By default the connect timeout is 5 sec.
            pop.ConnectTimeout = TimeSpan.FromSeconds(4);

            // Connect to POP server.
            pop.Connect();
            Console.WriteLine("Connected.");

            // Authenticate using the credentials; username and password.
            pop.Authenticate("<USERNAME>", "<PASSWORD>");
            Console.WriteLine("Authenticated.");
        }

        Console.WriteLine("Disconnected.");
    }
}
Imports System
Imports GemBox.Email
Imports GemBox.Email.Pop

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        ' Create new POP client.
        Using pop As New PopClient("<ADDRESS> (e.g. pop.gmail.com)")

            ' By default the connect timeout is 5 sec.
            pop.ConnectTimeout = TimeSpan.FromSeconds(4)

            ' Connect to POP server.
            pop.Connect()
            Console.WriteLine("Connected.")

            ' Authenticate using the credentials; username and password.
            pop.Authenticate("<USERNAME>", "<PASSWORD>")
            Console.WriteLine("Authenticated.")
        End Using

        Console.WriteLine("Disconnected.")
    End Sub
End Module

Even though POP protocol has largely been made obsolete by newer IMAP protocol, it's still widely used for simple email operations.

You can reuse the same connection that's established by the PopClient object and your email server multiple times.

When calling the PopClient.Authenticate method, the strongest possible authentication mechanism will be used from the PopClient.SupportedAuthentications collection.

To disconnect from the email server, you can use either the PopClient.Disconnect or PopClient.Dispose method.

Last, PopClient utilizes the following protocol's extensions:

Check next example or download examples from GitHub.