POP Email Client connection in C# and VB.NET

The Post Office Protocol (POP) was the first widely used protocol for receiving mail messages. Although it has largely been made obsolete by the Internet Message Access Protocol (IMAP), POP is still widely used for simple mail operations.

The GemBox.Email .NET component supports the latest version (version 3; POP3) and the following example demonstrates how to connect and authenticate with a mail server using the PopClient class in C# and VB.NET.

Screenshot
Connect with POP client Screenshot

See the full code below.

using GemBox.Email;
using GemBox.Email.Mime;
using GemBox.Email.Pop;
using GemBox.Email.Security;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        using (PopClient pop = new PopClient("<ADDRESS> (e.g. pop.gmail.com)"))
        {
            // Connect to mail server
            pop.Connect();
            Console.WriteLine("Connected.");

            // Authenticate with specified username and password
            // (PopClient will use strongest possible authentication mechanism)
            pop.Authenticate("<USERNAME>", "<PASSWORD>");
            Console.WriteLine("Authenticated.");
        }
    }
}
Imports System.Globalization
Imports System.Net.Security
Imports System.Security.Cryptography.X509Certificates
Imports GemBox.Email
Imports GemBox.Email.Mime
Imports GemBox.Email.Pop

Module Samples

    Sub Main()

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

        Using pop As New PopClient("<ADDRESS> (e.g. pop.gmail.com)")

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

            ' Authenticate with specified username and password
            ' (PopClient will use strongest possible authentication mechanism)
            pop.Authenticate("<USERNAME>", "<PASSWORD>")
            Console.WriteLine("Authenticated.")

        End Using

    End Sub

End Module