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 you can get the mail message count and overall mailbox size.

Mailbox information with POP client in C# and VB.NET
Screenshot of mailbox information from PopClient
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.

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Email yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.