Mail |
public void Connect( string host, int port, bool useSsl, CancellationToken cancellationToken = default )
| Exception | Condition |
|---|---|
| ArgumentNullException | The host is . |
| ArgumentOutOfRangeException | port is out of range (Field Value0 toField Value65535, inclusive). |
| ArgumentException | The host is a zero-length string. |
| 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. |
Establishes a connection to the specified mail server.
The useSsl argument only controls whether or not the client makes an SSL-wrapped connection. In other words, even if the useSsl parameter is , SSL/TLS may still be used if the mail server supports the STARTTLS extension. To disable all use of SSL/TLS, use the Connect(String, Int32, SecureSocketOptions, CancellationToken) overload with a value of SecureSocketOptions.None instead. |