Mailbox Info

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.

The following example shows how to get the mail message count and overall mailbox size.

Screenshot of mailbox information from PopClient
Mailbox information with POP client in C# and VB.NET
using System;
using GemBox.Email;
using GemBox.Email.Pop;

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

Module Program

    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()
            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

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

Check next example or download examples from GitHub.