Click or drag to resize
MimeKit

MailServiceDisconnect Method

Disconnect the service.

Namespace:  MailKit
Assembly:  MailKit (in MailKit.dll) Version: 2.3.0
Syntax
C#
public abstract void Disconnect(
	bool quit,
	CancellationToken cancellationToken = null
)

Parameters

quit
Type: SystemBoolean
If set to true, a logout/quit command will be issued in order to disconnect cleanly.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
The cancellation token.

Implements

IMailServiceDisconnect(Boolean, CancellationToken)
Exceptions
ExceptionCondition
ObjectDisposedException The MailService has been disposed.
Remarks
If quit is true, a logout/quit command will be issued in order to disconnect cleanly.
Examples
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);
    }
}
See Also