Occurs when the connection with the server gets closed.
Namespace: MailBee.Pop3MailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax Remarks This event is raised in all the cases when the connection gets closed, including
normal shutdown and failures.
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
{
private static void OnDisconnected(object sender, DisconnectedEventArgs e)
{
if (e.IsNormalShutdown)
{
Console.WriteLine("Normally disconnected from the server.");
}
else
{
Console.WriteLine("The connection was terminated.");
}
}
static void Main(string[] args)
{
Pop3 pop = new Pop3();
pop.Disconnected += new DisconnectedEventHandler(OnDisconnected);
pop.Connect("mail.domain.com");
pop.Timeout = 1000;
pop.ExecuteCustomCommand("NONSENSE", false);
pop.Disconnect();
}
}
Imports System
Imports MailBee
Imports MailBee.Pop3Mail
Class Sample
Private Shared Sub OnDisconnected(ByVal sender As Object, ByVal e As DisconnectedEventArgs)
If e.IsNormalShutdown Then
Console.WriteLine("Normally disconnected from the server.")
Else
Console.WriteLine("The connection was terminated.")
End If
End Sub
Shared Sub Main(ByVal args As String())
Dim pop As New Pop3
AddHandler pop.Disconnected, AddressOf OnDisconnected
pop.Connect("mail.domain.com")
pop.Timeout = 1000
pop.ExecuteCustomCommand("NONSENSE", False)
pop.Disconnect()
End Sub
End Class
See Also