ImapBeginLogin Method

Note: This API is now obsolete.

Begins an asynchronous request for a logging in an account on an IMAP4 server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
[ObsoleteAttribute("This method is obsolete in .NET 4.5+. Use LoginAsync instead.")]
public IAsyncResult BeginLogin(
	string targetName,
	string domain,
	string accountName,
	string password,
	AuthenticationMethods authMethods,
	AuthenticationOptions authOptions,
	SaslMethod authUserDefined,
	AsyncCallback callback,
	Object state
)

Parameters

targetName
Type: SystemString
The Service Principal Name of the server. Used only with GSSAPI/Kerberos authentication. You can leave it a null reference (Nothing in Visual Basic) or an empty string.
domain
Type: SystemString
The user account domain on the server. Used only with NTLM and GSSAPI authentication. You can leave it a null reference to use the current domain.
accountName
Type: SystemString
The user account name on the server. You can leave it a null reference when using NTLM or GSSAPI and wish to authenticate as the current Windows user.
password
Type: SystemString
The password of the user account on the server.
authMethods
Type: MailBeeAuthenticationMethods
A set of authentication methods which can be used when logging in a mailbox.
authOptions
Type: MailBeeAuthenticationOptions
Specifies the options which affect login process.
authUserDefined
Type: MailBeeSaslMethod
A reference to the instance of user defined authentication method, or a null reference (Nothing in Visual Basic) if user defined authentication is not used.
callback
Type: SystemAsyncCallback
The AsyncCallback delegate. You can leave it a null reference (Nothing in Visual Basic) if you do not use callbacks.
state
Type: SystemObject
An object that contains state information for this request. You can leave it a null reference (Nothing in Visual Basic).

Return Value

Type: IAsyncResult
An IAsyncResult that references the asynchronous login process.
Exceptions
ExceptionCondition
MailBeeInvalidStateExceptionThere is already an operation in progress.
Remarks
Examples
This sample demonstrates asynchronous logging in an account and use of a callback function in a console application.
using System;
using MailBee;
using MailBee.ImapMail;

class Sample
{
    // A callback function.
    private static void LoginCallback(IAsyncResult result)
    {
        Imap imp = (Imap)result.AsyncState;
        imp.EndLogin();
        imp.SelectFolder("INBOX");
        Console.WriteLine("Message #" + imp.Unseen + " is first unseen");
    }

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

        imp.Connect("imap.somehost.com");

        // Initiate an asynchronous login attempt.
        IAsyncResult ar = imp.BeginLogin(null, null, "jdoe", "secret",
            AuthenticationMethods.Auto, AuthenticationOptions.None,
            null, new AsyncCallback(LoginCallback), imp);

        // Simulate some lengthy work here. At the same time,
        // login is executed on another thread.
        System.Threading.Thread.Sleep(3000);

        // If the login attempt is still in progress, then wait until it's finished.
        while (imp.IsBusy) ar.AsyncWaitHandle.WaitOne();

        // Disconnect from the server.
        imp.Disconnect();
    }
}
See Also