|ImapLogin Method (String, String, AuthenticationMethods, AuthenticationOptions, SaslMethod)|
public bool Login( string accountName, string password, AuthenticationMethods authMethods, AuthenticationOptions authOptions, SaslMethod authUserDefined )
Public Function Login ( accountName As String, password As String, authMethods As AuthenticationMethods, authOptions As AuthenticationOptions, authUserDefined As SaslMethod ) As Boolean
By default, MailBee won't even try to use authentication methods which are not listed by the server in its capabilities. This behavior can be changed by setting TryUnsupportedMethods bit in authOptions. If, during the authentication attempt, the server reports that the method is unsupported, MailBee will try the next method in authMethods until the compatible method is found or no more methods left. This behavior can be changed by setting UseSingleMethodOnly bit in authOptions.
Authentication methods are tried from more secure to less secure. If authMethods is set to Auto and authOptions is None, 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. However, if the IMAP4 server prohibits using LOGIN command (LOGINDISABLED extension is enabled), regular authentication option won't be available.
To use OAuth 2.0 authentication (XOAUTH2 in Gmail), see the example in OAuth2 topic.
// 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(null, null, AuthenticationMethods.SaslNtlm, AuthenticationOptions.TryUnsupportedMethods, null); imp.Disconnect();
' 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(Nothing, Nothing, AuthenticationMethods.SaslNtlm, AuthenticationOptions.TryUnsupportedMethods, Nothing) imp.Disconnect()