Email Email Message Headers with POP

The following example shows how you can use the GemBox.Email component to receive email message headers using PopClient, in your C# and VB.NET applications.

using GemBox.Email;
using GemBox.Email.Mime;
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");

        using (PopClient pop = new PopClient("<ADDRESS> (e.g. pop.gmail.com)"))
        {
            pop.Connect();
            pop.Authenticate("<USERNAME>", "<PASSWORD>");

            // Get headers for first available mail message.
            HeaderCollection headers = pop.GetHeaders(1);

            // Display message headers.
            foreach (Header header in headers)
                Console.WriteLine($"{header.Name}: {header.Body}");
        }
    }
}
Imports GemBox.Email
Imports GemBox.Email.Mime
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")

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

            pop.Connect()
            pop.Authenticate("<USERNAME>", "<PASSWORD>")

            ' Get headers for first available mail message.
            Dim headers As HeaderCollection = pop.GetHeaders(1)

            ' Display message headers.
            For Each header As Header In headers
                Console.WriteLine($"{header.Name}: {header.Body}")
            Next
        End Using
    End Sub
End Module
Message headers with POP client in C# and VB.NET
Screenshot of message headers from PopClient

Apart from retrieving full mail messages, can also enable you to get only the message headers. The headers contain information related to the message content and metadata. For more details, check out our Headers example.

To obtain the message headers, you need to use one of the PopClient.GetHeaders methods. The result is a HeaderCollection object, which contains a collection of Header objects.

For more information about PopClient, check out our POP Client Connection example.

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