Smtp ClientDisconnect Method
Disconnect the service.
Definition
Namespace: MailKit.Net.Smtp
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
IMailServiceDisconnect(Boolean, CancellationToken)
Assembly: MailKit (in MailKit.dll) Version: 5.0.0
C#
public override void Disconnect(
bool quit,
CancellationToken cancellationToken = default
)Parameters
- quit Boolean
- If set to , a QUIT command will be issued in order to disconnect cleanly.
- cancellationToken CancellationToken (Optional)
- The cancellation token.
Implements
IMailServiceDisconnect(Boolean, CancellationToken)IMailServiceDisconnect(Boolean, CancellationToken)
Remarks
If quit is , a QUIT command will be issued in order to disconnect cleanly.
Example
C#
public static void SendMessage (MimeMessage message)
{
using (var client = new SmtpClient ()) {
client.Connect ("smtp.gmail.com", 465, SecureSocketOptions.SslOnConnect);
client.Authenticate ("username", "password");
client.Send (message);
client.Disconnect (true);
}
}
Exceptions
| ObjectDisposedException | The SmtpClient has been disposed. |