Click or drag to resize
MimeKit

MailServiceConnectAsync Method (Uri, CancellationToken)

Asynchronously establish a connection to the specified mail server.

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

Parameters

uri
Type: SystemUri
The server URI.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
The cancellation token.

Return Value

Type: 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