Crystalbyte.Equinox.Imap.ImapClient.Send C# (CSharp) Method

Send() public method

Sends a command to the server.
public Send ( ImapCommand command ) : void
command ImapCommand The command to issue.
return void
        public void Send(ImapCommand command)
        {
            var commandString = command.ToString();
            WriteLine(commandString);
        }

Usage Example

コード例 #1
0
        private bool AuthenticatePlain(NetworkCredential credentials)
        {
            var capabilities = _client.ServerCapability;
            var username     = credentials.UserName;
            var password     = credentials.Password;

            var auth        = username + "\0" + username + "\0" + password;
            var encodedAuth = Base64Encoder.Encode(auth);

            if (capabilities.IsInitialClientResponseSupported)
            {
                var text    = string.Format("AUTHENTICATE PLAIN {0}", encodedAuth);
                var command = new ImapCommand(text);
                return(_client.SendAndReceive(command).IsOk);
            }

            var authCommand = new ImapCommand("AUTHENTICATE PLAIN");
            var response    = _client.SendAndReceive(authCommand);

            if (response.IsContinuation)
            {
                var command = new BlankImapCommand(encodedAuth);
                _client.Send(command);
                return(_client.Receive().IsOk);
            }

            return(false);
        }