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

Mailbox Info

The following example shows the fastest way to check for new messages on the server using the GemBox.Email component. It also demonstrates how to get the overall mailbox size.

Screenshot
Mailbox Info Screenshot

See the full code below.

using GemBox.Email;
using GemBox.Email.Mime;
using GemBox.Email.Pop;
using GemBox.Email.Security;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

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

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

            // Get size of all available messages in bytes
            Console.WriteLine("Mailbox size: {0} Byte(s)", pop.GetSize());
        }
    }
}
Imports System.Globalization
Imports System.Net.Security
Imports System.Security.Cryptography.X509Certificates
Imports GemBox.Email
Imports GemBox.Email.Mime
Imports GemBox.Email.Pop

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

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

            ' Get size of all available messages in bytes
            Console.WriteLine("Mailbox size: {0} Byte(s)", pop.GetSize())

        End Using

    End Sub

End Module

Check next sample.