MailBee.NET Objects 4.0

Pop3.LoggedIn Event

Occurs when the component successfully authenticates the user on the 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

After raising this event, the component will download the mailbox statistics from the mail server (number of messages in the mailbox, and other information as specified by InboxPreloadOptions property setting.

Example

This sample connects to the POP3 server, logs in the user account, and downloads the complete mailbox statistics. The sample demonstrates there is a delay between LoggedIn event occurence and Login method completion, which is the amount of time spent on downloading the mailbox statistics after completion of the authentication process.

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

class Sample
{
    // LoggedIn event handler.
    private static void OnLoggedIn(object sender, LoggedInEventArgs e)
    {
        Console.WriteLine("Successfully logged in the user account at " +
            (DateTime.Now - DateTime.Today));
    }

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

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

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

        // Set "download the complete mailbox statistics" mode to increase the delay 
        // between LoggedIn event and Login method completion 
        pop.InboxPreloadOptions = Pop3InboxPreloadOptions.List | Pop3InboxPreloadOptions.Uidl;

        // Authenticate the user, log in the mailbox, and download the mailbox statistics.
        pop.Login("jdoe", "secret");

        Console.WriteLine("The user account statistics received at " +
            (DateTime.Now - DateTime.Today));

        pop.Disconnect();
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.Pop3Mail

Class Sample
    ' LoggedIn event handler.
    Private Shared Sub OnLoggedIn(ByVal sender As Object, ByVal e As LoggedInEventArgs)
        Dim DNow As DateTime = DateTime.Now
        Dim DToday As DateTime = DateTime.Today
        Console.WriteLine("Successfully logged in the user account at " & _
            DateDiff(DateInterval.Hour, DateTime.Now, DateTime.Today))
    End Sub

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

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

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

        ' Set "download the complete mailbox statistics" mode to increase the delay 
        ' between LoggedIn event and Login method completion.
        pop.InboxPreloadOptions = Pop3InboxPreloadOptions.List Or Pop3InboxPreloadOptions.Uidl

        ' Authenticate the user, log in the mailbox, and download the mailbox statistics.
        pop.Login("jdoe", "secret")

        Console.WriteLine("The user account statistics received at " & _
            DateDiff(DateInterval.Hour, DateTime.Now, DateTime.Today))

        pop.Disconnect()
    End Sub
End Class

See Also

Pop3 Class | MailBee.Pop3Mail Namespace | Login