Pop3Disconnected Event
Occurs when the connection with the server gets closed.

Namespace: MailBee.Pop3Mail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public event DisconnectedEventHandler Disconnected

Value

Type: MailBeeDisconnectedEventHandler
Remarks
This event is raised in all the cases when the connection gets closed, including normal shutdown and failures.
Note Note
If Abort method is called, the connection is immediately closed, but no events (including Disconnected) are raised any longer.
Examples
This sample demonstrates that Disconnected event raises even on failures (when MailBeeException is thrown). The sample connects to the POP3 server and then sends invalid data to the server. The server does not respond and the network operation times out.
using System;
using MailBee;
using MailBee.Pop3Mail;

class Sample
{
    // Disconnected event handler.
    private static void OnDisconnected(object sender, DisconnectedEventArgs e)
    {
        if (e.IsNormalShutdown)
        {
            // QUIT command was sent to POP3 server.
            Console.WriteLine("Normally disconnected from the server.");
        }
        else
        {
            // Rough disconnect (due to failure). If any messages have been 
            // flagged for deletion, they will possibly not be deleted.
            Console.WriteLine("The connection was terminated.");
        }
    }

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

        // Subscribe to Disconnected event.
        pop.Disconnected += new DisconnectedEventHandler(OnDisconnected);

        pop.Connect("mail.domain.com");

        // We do not want to wait too long. Set one second as timeout value.
        pop.Timeout = 1000;

        // Simulate connection error by sending a request to which the POP3
        // server will never respond (due to a lack of "\r\n" in the request data).
        // This will cause MailBee to terminate the connection and raise 
        // Disconnected event, and then throw MailBeeException (exceptions are 
        // enabled by default).
        pop.ExecuteCustomCommand("NONSENSE", false);

        // This line will probably never execute (unless the server 
        // suddenly responds to NONSENSE sequence of bytes).
        pop.Disconnect();
    }
}
See Also