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

Receive Email in C# and VB.NET

The following example shows how to check for new messages on the server and how to receive those emails in C# and VB.NET using PopClient.

The downloaded email messages are written to the Console output.

Screenshot
Receive Screenshot

See the full code below.

using GemBox.Email;
using GemBox.Email.Imap;
using GemBox.Email.Mime;
using GemBox.Email.Pop;
using GemBox.Email.Smtp;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;

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)"))
        {
            pop.Connect();
            Console.WriteLine("Connected.");

            pop.Authenticate("<USERNAME>", "<PASSWORD>");
            Console.WriteLine("Authenticated.");

            // Read the number of currently available email messages on the server.
            int count = pop.GetCount();
            Console.WriteLine("Number of available messages: " + count);

            // Write table header
            Console.WriteLine();
            Console.WriteLine(" NO. |         DATE        |        SUBJECT");
            Console.WriteLine("--------------------------------------------------");

            // Receive (download) and list all email messages.
            for (int i = 1; i <= count; i++)
            {
                MailMessage message = pop.GetMessage(i);
                Console.WriteLine("  {0,-2} | {1} | {2}", i, message.Date.ToString(CultureInfo.InvariantCulture), message.Subject);
            }
        }
    }
}
Imports System.Globalization
Imports System.Text
Imports GemBox.Email
Imports GemBox.Email.Imap
Imports GemBox.Email.Mime
Imports GemBox.Email.Pop
Imports GemBox.Email.Smtp

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)")
            pop.Connect()
            Console.WriteLine("Connected.")

            pop.Authenticate("<USERNAME>", "<PASSWORD>")
            Console.WriteLine("Authenticated.")

            ' Read the number of currently available email messages on the server.
            Dim count As Integer = pop.GetCount()
            Console.WriteLine("Number of available messages: " & count)

            ' Write table header
            Console.WriteLine()
            Console.WriteLine(" NO. |         DATE        |        SUBJECT")
            Console.WriteLine("--------------------------------------------------")

            ' Receive (download) and list all email messages.
            For i As Integer = 1 To count
                Dim message As MailMessage = pop.GetMessage(i)
                Console.WriteLine("  {0,-2} | {1} | {2}", i, message.Date.ToString(CultureInfo.InvariantCulture), message.Subject)
            Next
        End Using

    End Sub

End Module

Check next sample.