The event handler receives an argument of type ConnectedEventArgs containing data related to this event. The following ConnectedEventArgs properties provide information specific to this event.
| Property | Description |
|---|---|
| Protocol | Gets application-level protocol of the established connection. |
| RemoteEndPoint | Gets a reference to the end point of the remote host to which the connection was established. |
| RemoteHostName | Gets the name of the remote host to which the connection was established. |
| State | Gets a reference to the object which was supplied by the developer in state parameter of asynchronous methods of the mailer components. |
This event indicates successful completion of the connection procedure, while SocketConnected event (occurs before Connected) indicates the connection request from MailBee was accepted by the server, and the POP3 connection procedure will now begin.
This sample uses Connected event to report the successful connection status into console.
[C#] using System; using MailBee; using MailBee.Pop3Mail; class Sample { // Connected event handler. private static void OnConnected(object sender, ConnectedEventArgs e) { Console.WriteLine("Successfully connected to the server."); } // The actual code. static void Main(string[] args) { Pop3 pop = new Pop3(); // Subscribe to Connected event. pop.Connected += new ConnectedEventHandler(OnConnected); pop.Connect("mail.domain.com"); pop.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.Pop3Mail Class Sample ' Connected event handler. Private Shared Sub OnConnected(ByVal sender As Object, ByVal e As ConnectedEventArgs) Console.WriteLine("Successfully connected to the server.") End Sub ' The actual code. Shared Sub Main(ByVal args As String()) Dim pop As New Pop3 ' Subscribe to Connected event. AddHandler pop.Connected, AddressOf OnConnected pop.Connect("mail.domain.com") pop.Disconnect() End Sub End Class
Pop3 Class | MailBee.Pop3Mail Namespace | SocketConnected