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.

using System;
using GemBox.Email;
using GemBox.Email.Pop;
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 System
Imports GemBox.Email
Imports GemBox.Email.Pop
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
For more information about PopClient
, check out our POP Client Connection example.
See also
Next steps
Published: October 30, 2018 | Modified: December 19, 2022 | Author: Marko Kozlina