Get the mailbox information from POP3 Client

The following example shows how you can use the GemBox.Email library to get the mail message count and overall mailbox size.

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");

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

            // Get number of available messages.
            Console.WriteLine($"Mailbox message count: {pop.GetCount()}");

            // Get size of all available messages in bytes.
            Console.WriteLine($"Mailbox size: {pop.GetSize()} Byte(s)");
        }
    }
}
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")

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

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

            ' Get number of available messages.
            Console.WriteLine($"Mailbox message count: {pop.GetCount()}")

            ' Get size of all available messages in bytes
            Console.WriteLine($"Mailbox size: {pop.GetSize()} Byte(s)")
        End Using
    End Sub
End Module
Mailbox information with POP client in C# and VB.NET
Screenshot of mailbox information from PopClient

The fastest way how to detect a change on your email server with GemBox.Email is to periodically call a PopClient.GetCount method in order to get the number of currently available messages on the server. By checking the message count, you can determine if the new message(s) was received or if the existing message(s) was removed.

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