Pop3ErrorOccurred Event
Occurs when the MailBeeException is thrown.

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
public event ErrorEventHandler ErrorOccurred


Type: MailBeeErrorEventHandler

When MailBee encounters any error, it throws the MailBeeException. However, MailBee can trap this exception if the error was not critical. For instance, if the POP3 server responds with a negative reply to an optional POP3 command (such as CAPA), the MailBeeException will be thrown and then trapped by MailBee itself, but no exception will be thrown to the application code. Such errors are called warnings.

ErrorOccurred event allows the developer to track both warnings and critical errors because it's raised for a particular exception even if MailBee will trap this exception and do not pass it to the application code.

This sample logs all the warnings and critical errors issued during the POP3 session into the console. If the connection succeeds and the POP3 server does support CAPA command, no output will be produced. The sample is written for a console application.
using System;
using MailBee;
using MailBee.Pop3Mail;

class Sample
    // ErrorOccurred event handler.
    private static void OnErrorOccurred(object sender, ErrorEventArgs e)
        // Check whether the error is critical or not.
        if (e.IsFinalError)
            // Display corresponding MailBeeException.Message.
            // After OnErrorOccurred handler finishes, MailBee will 
            // throw the same exception to the application code.
            Console.WriteLine("CRITICAL ERROR: " + e.Reason.Message);
            // Display corresponding MailBeeException.Message.
            // After OnErrorOccurred handler finishes, MailBee will 
            // try another methods to accomplish the current task.
            Console.WriteLine("WARNING: " + e.Reason.Message);

    // The actual code.
    static void Main(string[] args)
        Pop3 pop = new Pop3();

        // Subscribe to the ErrorOccurred event.
        pop.ErrorOccurred += new ErrorEventHandler(OnErrorOccurred);

        // Connect to the server.

        // Request any data which needs CAPA command to be issued 
        // in order to obtain the required information. The list of supported 
        // authentication methods can serve this purpose. If CAPA command 
        // fails (but the server responds, i.e. the connection itself is still valid),
        // MailBee will not throw any exception to the application code  
        // (but ErrorOccurred event will still be raised) and will try to issue 
        // AUTH command to get the list of supported authentication methods.
        // If AUTH command fails too, it's still not a critical error. SASL 
        // authentication methods will just not be available.
        AuthenticationMethods authMethods = pop.GetSupportedAuthMethods();

        // Close the connection
See Also