Click or drag to resize
MimeKit

SmtpClientAuthenticateAsync Method (SaslMechanism, CancellationToken)

Asynchronously authenticate using the specified SASL mechanism.

Namespace:  MailKit.Net.Smtp
Assembly:  MailKit (in MailKit.dll) Version: 2.3.0
Syntax
C#
public override Task AuthenticateAsync(
	SaslMechanism mechanism,
	CancellationToken cancellationToken = null
)

Parameters

mechanism
Type: MailKit.SecuritySaslMechanism
The SASL mechanism.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
The cancellation token.

Return Value

Type: Task
An asynchronous task context.

Implements

IMailServiceAuthenticateAsync(SaslMechanism, CancellationToken)
Exceptions
ExceptionCondition
ArgumentNullExceptionmechanism is null.
ServiceNotConnectedException The SmtpClient is not connected.
InvalidOperationException The SmtpClient is already authenticated.
NotSupportedException The SMTP server does not support authentication.
OperationCanceledException The operation was canceled via the cancellation token.
AuthenticationException Authentication using the supplied credentials has failed.
SaslException A SASL authentication error occurred.
IOException An I/O error occurred.
SmtpCommandException The SMTP command failed.
SmtpProtocolException An SMTP protocol error occurred.
Remarks

Authenticates using the specified SASL mechanism.

For a list of available SASL authentication mechanisms supported by the server, check the AuthenticationMechanisms property after the service has been connected.

See Also