MailKit.Net.Imap.ImapClient.Reconnect C# (CSharp) Метод

Reconnect() публичный Метод

Reconnect to the most recently connected IMAP server.

Reconnects to the most recently connected IMAP server. Once a successful connection is made, the session will then be re-authenticated using the account name used in the previous session and the password.

/// is null. /// /// The has been disposed. /// /// The is not connected. /// /// There is no previous session to restore. /// /// The operation was canceled via the cancellation token. /// /// Authentication using the supplied credentials has failed. /// /// A SASL authentication error occurred. /// /// The previous session was using the STARTTLS extension but the /// IMAP server no longer supports it. /// /// An I/O error occurred. /// /// An IMAP protocol error occurred. ///
public Reconnect ( string password, CancellationToken cancellationToken = default(CancellationToken) ) : void
password string The password.
cancellationToken System.Threading.CancellationToken The cancellation token.
Результат void
		public void Reconnect (string password, CancellationToken cancellationToken = default (CancellationToken))
		{
			if (password == null)
				throw new ArgumentNullException ("password");

			if (identifier == null)
				throw new InvalidOperationException ("There is no previous session to restore.");

			// Note: the identifier has the following syntax: imap(s)://userName@host:port
			int startIndex = identifier.IndexOf (':') + 3;
			int endIndex = identifier.IndexOf ('@');

			var userName = UnescapeUserName (identifier.Substring (startIndex, endIndex - startIndex));

			Connect (engine.Uri, cancellationToken);

			Authenticate (userName, password, cancellationToken);
		}