MailBee.NET Objects 4.0

Imap.Login Method (String, String, AuthenticationMethods)

Logs in a mail account on the IMAP4 server.

public bool Login(
   string accountName,
   string password,
   AuthenticationMethods authMethods
);

Parameters

accountName
The user account name on the server.
password
The password of the user account on the server.
authMethods
A set of authentication methods which can be used when logging in a mailbox.

Return Value

true if a login attempt succeeded; otherwise, false.

Remarks

Authentication methods are tried from more secure to less secure. If authMethods is set to Auto, MailBee will try to use the most secure method supported by the server but will downgrade to less secure methods (to the simplest "LOGIN account password" authentication in the worst case) if better methods are not available.

Exceptions

Exception Type Condition
MailBeeException An error occurred and ThrowExceptions is true.

Example

This sample connects to an IMAP4 server and logs in a user account using secure authentication methods only. Use of insecure methods is not allowed.

[C#]
// To use the code below, import MailBee namespaces at the top of your code.
using MailBee;
using MailBee.ImapMail;

// The actual code (put it into a method of your class).
Imap imp = new Imap();
imp.Connect("mail.domain.com");
imp.Login("jdoe@domain.com", "secret", AuthenticationMethods.SaslCramMD5 | AuthenticationMethods.SaslNtlm);
imp.Disconnect();
[Visual Basic]
' To use the code below, import MailBee namespaces at the top of your code.
Imports MailBee
Imports MailBee.ImapMail

' The actual code (put it into a method of your class).
Dim imp As New Imap
imp.Connect("mail.domain.com")
imp.Login("jdoe@domain.com", "secret", AuthenticationMethods.SaslCramMD5 Or AuthenticationMethods.SaslNtlm)
imp.Disconnect()

See Also

Imap Class | MailBee.ImapMail Namespace | Imap.Login Overload List