ImapLogin Method (String, String)
Logs in a mail account on the IMAP4 server.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public bool Login(
	string accountName,
	string password
)

Parameters

accountName
Type: SystemString
The user account name on the server.
password
Type: SystemString
The password of the user account on the server.

Return Value

Type: Boolean
true if a login attempt succeeded; otherwise, false.
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks

This method will try to authenticate using the best (the most secure) authentication 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.

You can also force using a particular authentication method with Login(String, String, AuthenticationMethods) overload passing a method like Regular.

Note Note
If SafeMode is true, MailBee will use the simplest "LOGIN account password" authentication by default (Regular option). This can often help to troubleshoot login problems (some mail servers implement secure authentication methods incorrectly).
To use OAuth 2.0 authentication (XOAUTH2 in Gmail), see the example in OAuth2 topic.
Examples
This sample connects to an IMAP4 server, logs in a user account, selects Inbox folder, and displays the total number of messages in this folder.
// 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", "secret");
imp.SelectFolder("INBOX");
Console.WriteLine(imp.MessageCount + " message(s) in inbox");
imp.Disconnect();
See Also