Connect to POP3 Client

The following example shows how to connect to, authenticate with, and disconnect from a remote POP3 server using the GemBox.Email library.

using GemBox.Email;
using GemBox.Email.Pop;
using System;

class Program
{
    static void Main()
    {
        // If using the 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 GemBox.Email
Imports GemBox.Email.Pop
Imports System

Module Program

    Sub Main()

        ' If using the 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
Using a POP3 client in C# and VB.NET
Screenshot of PopClient's output

The Post Office Protocol (POP) was the first widely used protocol for receiving mail messages and although it has largely been made obsolete by the IMAP protocol, it's still widely used for simple email operations.

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.

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 password-based 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:

See also


Next steps

GemBox.Email is a .NET component that enables you to read, write, receive, and send emails from your .NET applications using one simple API.

Download Buy