Click or drag to resize
MimeKit

IMailServiceConnectAsync Method (String, Int32, Boolean, CancellationToken)

Asynchronously establish a connection to the specified mail server.

Namespace:  MailKit
Assembly:  MailKit (in MailKit.dll) Version: 2.7.0
Syntax
C#
Task ConnectAsync(
	string host,
	int port,
	bool useSsl,
	CancellationToken cancellationToken = null
)

Parameters

host
Type: SystemString
The host name to connect to.
port
Type: SystemInt32
The port to connect to. If the specified port is 0, then the default port will be used.
useSsl
Type: SystemBoolean

Field Value

Type: Task
true if the client should make an SSL-wrapped connection to the server; otherwise,

Field Value

Type: Task
false.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
The cancellation token.

Return Value

Type: Task
An asynchronous task context.
Exceptions
ExceptionCondition
ArgumentNullException The host is null.
ArgumentOutOfRangeExceptionport is not between 0 and 65535.
ArgumentException The host is a zero-length string.
ObjectDisposedException The IMailService has been disposed.
InvalidOperationException The IMailService is already connected.
OperationCanceledException The operation was canceled via the cancellation token.
IOException An I/O error occurred.
ProtocolException A protocol error occurred.
Remarks

Asynchronously establishes a connection to the specified mail server.

If a successful connection is made, the AuthenticationMechanisms property will be populated.

See Also