Attempts to establish an authenticated session with the server using the specified
credentials.
Namespace: S22.ImapAssembly: 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
Exception | Condition |
---|---|
System..::..ArgumentNullException | The username parameter or the password parameter is null. |
System.IO..::..IOException | There was a failure writing to or reading from the network. |
S22.Imap..::..InvalidCredentialsException | The server rejected the supplied credentials. |
System..::..NotSupportedException | The specified authentication method is not supported by the server. |