Attempts to establish an authenticated session with the server using the specified credentials.

Namespace: S22.Imap
Assembly: S22.Imap (in S22.Imap.dll) Version: 3.6.0.0 (3.6.0.0)

Syntax

C#
public void Login(
	string username,
	string password,
	AuthMethod method
)

Parameters

username
Type: System..::..String
The username with which to login in to the IMAP server.
password
Type: System..::..String
The password with which to log in to the IMAP server.
method
Type: S22.Imap..::..AuthMethod
The requested method of authentication. Can be one of the values of the AuthMethod enumeration.

Implements

IImapClient..::..Login(String, String, AuthMethod)

Examples

This example demonstrates how to authenticate with an IMAP server once a connection has been established. Notice that you can also connect and login in one step using one of the overloaded constructors.
CopyC#
// Connect to Gmail's IMAP server on port 993 using SSL.
ImapClient Client = new ImapClient("imap.gmail.com", 993, true);

try {
    Client.Login("My_Username", "My_Password", AuthMethod.Auto);
}
catch(InvalidCredentialsException) {
    Console.WriteLine("The server rejected the supplied credentials.");
}

Client.Dispose();

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionThe username parameter or the password parameter is null.
System.IO..::..IOExceptionThere was a failure writing to or reading from the network.
S22.Imap..::..InvalidCredentialsExceptionThe server rejected the supplied credentials.
System..::..NotSupportedExceptionThe specified authentication method is not supported by the server.

See Also