MailBee.NET Objects 4.0

Smtp.LoggedIn Event

Occurs when the component successfully authenticates the user on the SMTP server and logs in the user account.

public event LoggedInEventHandler LoggedIn;

Event Data

The event handler receives an argument of type LoggedInEventArgs containing data related to this event. The following LoggedInEventArgs properties provide information specific to this event.

Property Description
Protocol Gets application-level protocol of the current connection.
RemoteEndPoint Gets a reference to the end point of the server host.
RemoteHostName Gets the host name of the server.
State Gets a reference to the object which was supplied by the developer in state parameter of asynchronous methods of the mailer components.

Remarks

This event is raised only as a result of ESMTP authentication (performed by Login method). Successful completion of POP-before-SMTP authentication does not cause this event to be raised.

Example

This sample connects to the SMTP server, and then authenticates the user on the server.

[C#]
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
{
    // LoggedIn event handler.
    private static void OnLoggedIn(object sender, LoggedInEventArgs e)
    {
        Console.WriteLine("Successfully authenticated on the SMTP server");
    }

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

        // Specify SMTP server and enable ESMTP authentication.
        // Note, depending on your SMTP server settings, either jdoe or jdoe@domain.com 
        // should be used as user account name.
        mailer.SmtpServers.Add("smtp.domain.com", "jdoe@domain.com", "secret");

        // Subscribe to the LoggedIn event.
        mailer.LoggedIn += new LoggedInEventHandler(OnLoggedIn);

        mailer.Connect();
        mailer.Hello();
        mailer.Login();
        mailer.Disconnect();
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.SmtpMail

Class Sample
    ' Connected event handler.
    Private Shared Sub OnLoggedIn(ByVal sender As Object, ByVal e As LoggedInEventArgs)
        Console.WriteLine("Successfully authenticated on the SMTP server")
    End Sub

    ' The actual code.
    Shared Sub Main(ByVal args As String())
        Dim mailer As New Smtp

        ' Specify SMTP server and enable ESMTP authentication.
        ' Note, depending on your SMTP server settings, either jdoe or jdoe@domain.com 
        ' should be used as user account name.
        mailer.SmtpServers.Add("smtp.domain.com", "jdoe@domain.com", "secret")

        ' Subscribe to the LoggedIn event.
        AddHandler mailer.LoggedIn, AddressOf OnLoggedIn

        mailer.Connect()
        mailer.Hello()
        mailer.Login()
        mailer.Disconnect()
    End Sub
End Class

See Also

Smtp Class | MailBee.SmtpMail Namespace | Login