Click or drag to resize
MimeKit

MailServiceConnectAsync(Uri, CancellationToken) Method

Asynchronously establish a connection to the specified mail server.

Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 4.7.1
Syntax
C#
public Task ConnectAsync(
	Uri uri,
	CancellationToken cancellationToken = default
)

Parameters

uri  Uri
The server URI.
cancellationToken  CancellationToken  (Optional)
The cancellation token.

Return Value

Task
An asynchronous task context.
Exceptions
ExceptionCondition
ArgumentNullException The uri is null.
ArgumentException The uri is not an absolute URI.
ObjectDisposedException The MailService has been disposed.
InvalidOperationException The MailService is already connected.
OperationCanceledException The operation was canceled via the cancellation token.
SocketException A socket error occurred trying to connect to the remote host.
IOException An I/O error occurred.
ProtocolException A protocol error occurred.
Remarks
Asynchronously establishes a connection to the specified mail server.
See Also