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 IMAP4 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.ImapMail; 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) { Imap imp = new Imap(); // Subscribe to Connected event. imp.Connected += new ConnectedEventHandler(OnConnected); imp.Connect("imap.domain.com"); imp.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Module Sample ' Connected event handler. Private Sub OnConnected(ByVal sender As Object, ByVal e As ConnectedEventArgs) Console.WriteLine("Successfully connected to the server.") End Sub ' The actual code. Sub Main(ByVal args As String()) Dim imp As New Imap ' Subscribe to Connected event. AddHandler imp.Connected, AddressOf OnConnected imp.Connect("imap.domain.com") imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace | SocketConnected