示例#1
0
        /// <summary>
        /// Begins an asynchronous request for a remote server secure connection.
        /// </summary>
        /// <param name="serverEncryption">Server encryption (SslTls, Unencrypted, StartTls)</param>
        /// <param name="host">The name or IP address of the remote server.</param>
        /// <returns>An IAsyncResult that references the asynchronous connection.</returns>
        public IAsyncResult BeginConnect(MailServerEncryption serverEncryption, string host)
        {
            switch (serverEncryption)
            {
            case MailServerEncryption.SslTls:
            {
                return(_pop3.BeginConnectSSL(host));
            }

            case MailServerEncryption.Unencrypted:
            {
                return(_pop3.BeginConnect(host));
            }

            case MailServerEncryption.StartTls:
            {
                var asyncResult = _pop3.BeginConnect(host);
                _pop3.StartTLS();
                return(asyncResult);
            }

            default:
            {
                return(_pop3.BeginConnect(host));
            }
            }
        }