Pop 3ClientDisconnect Method
Disconnect the service.
Definition
Namespace: MailKit.Net.Pop3
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 DownloadMessages ()
{
using (var client = new Pop3Client ()) {
client.Connect ("pop.gmail.com", 995, SecureSocketOptions.SslOnConnect);
client.Authenticate ("username", "password");
for (int i = 0; i < client.Count; i++) {
var message = client.GetMessage (i);
// write the message to a file
message.WriteTo (string.Format ("{0}.eml", i));
// mark the message for deletion
client.DeleteMessage (i);
}
client.Disconnect (true);
}
}
Exceptions
| ObjectDisposedException | The Pop3Client has been disposed. |