MailKit.Net.Smtp.SmtpClient.NoOp C# (CSharp) Method

NoOp() public method

Ping the SMTP server to keep the connection alive.
Mail servers, if left idle for too long, will automatically drop the connection.
/// The has been disposed. /// /// The is not connected. /// /// The operation was canceled. /// /// An I/O error occurred. /// /// The SMTP command failed. /// /// An SMTP protocol error occurred. ///
public NoOp ( CancellationToken cancellationToken = default(CancellationToken) ) : void
cancellationToken System.Threading.CancellationToken The cancellation token.
return void
		public override void NoOp (CancellationToken cancellationToken = default (CancellationToken))
		{
			CheckDisposed ();

			if (!IsConnected)
				throw new ServiceNotConnectedException ("The SmtpClient is not connected.");

			var response = SendCommand ("NOOP", cancellationToken);

			if (response.StatusCode != SmtpStatusCode.Ok)
				throw new SmtpCommandException (SmtpErrorCode.UnexpectedStatusCode, response.StatusCode, response.Response);
		}