예제 #1
0
        /// <summary>
        /// Loads settings from the Registry.
        /// </summary>
        void LoadConfig()
        {
            _sec     = (SecurityMode)Util.GetIntProperty("SecurityMode", 0);
            _sign    = (string)Util.GetProperty("Sign", "False") == "True";
            _encrypt = (string)Util.GetProperty("Encrypt", "False") == "True";
            _cert    = (string)Util.GetProperty("Cert", string.Empty);
            _tls     = (string)Util.GetProperty("TLS", "True") == "True";
            _ssl     = (string)Util.GetProperty("SSL", "True") == "True";
            _suites  = Util.GetIntProperty("Suites", 0);

            _server   = (string)Util.GetProperty("SmtpServer", string.Empty);
            _port     = Util.GetIntProperty("SmtpPort", 25);
            _userName = (string)Util.GetProperty("UserName", string.Empty);
            _password = (string)Util.GetProperty("Password", string.Empty);
            _method   = (SmtpAuthenticationMethod)Util.GetIntProperty("SmtpAuthenticationMethod", 0);
            _timeout  = Util.GetIntProperty("Timeout", 60000);

            _proxyServer               = (string)Util.GetProperty("ProxyServer", string.Empty);
            _proxyUserName             = (string)Util.GetProperty("ProxyUserName", string.Empty);
            _proxyPassword             = (string)Util.GetProperty("ProxyPassword", string.Empty);
            _proxyDomain               = (string)Util.GetProperty("ProxyDomain", string.Empty);
            _proxyPort                 = Util.GetIntProperty("ProxyPort", 1080);
            _proxyAuthenticationMethod = (ProxyHttpConnectAuthMethod)Util.GetIntProperty("ProxyAuthentication", 0);
            _proxyType                 = (ProxyType)Util.GetIntProperty("ProxyType", 0);
        }
예제 #2
0
        /// <summary>
        /// Handles the Settings toolbar button's Click event.
        /// </summary>
        /// <param name="sender">The button object.</param>
        /// <param name="e">The event arguments.</param>
        private void tsbSettings_Click(object sender, EventArgs e)
        {
            Settings sec = new Settings();

            sec.Security = _sec;
            sec.Sign     = _sign;
            sec.Encrypt  = _encrypt;
            sec.Cert     = _cert;
            sec.Suites   = _suites;
            sec.Server   = _server;
            sec.Port     = _port;
            sec.UserName = _userName;
            sec.Password = _password;
            sec.Method   = _method;
            sec.Timeout  = _timeout;

            // Proxy Settings
            sec.ProxyServer               = _proxyServer;
            sec.ProxyPort                 = _proxyPort;
            sec.ProxyUserName             = _proxyUserName;
            sec.ProxyPassword             = _proxyPassword;
            sec.ProxyDomain               = _proxyDomain;
            sec.ProxyAuthenticationMethod = _proxyAuthenticationMethod;
            sec.ProxyType                 = _proxyType;

            // Popups the Settings form.
            if (sec.ShowDialog() == DialogResult.OK)
            {
                _sec      = sec.Security;
                _sign     = sec.Sign;
                _encrypt  = sec.Encrypt;
                _cert     = sec.Cert;
                _suites   = sec.Suites;
                _server   = sec.Server;
                _port     = sec.Port;
                _userName = sec.UserName;
                _password = sec.Password;
                _method   = sec.Method;
                _timeout  = sec.Timeout;

                _proxyServer               = sec.ProxyServer;
                _proxyPort                 = sec.ProxyPort;
                _proxyUserName             = sec.ProxyUserName;
                _proxyPassword             = sec.ProxyPassword;
                _proxyDomain               = sec.ProxyDomain;
                _proxyAuthenticationMethod = sec.ProxyAuthenticationMethod;
                _proxyType                 = sec.ProxyType;
            }
        }
예제 #3
0
        /// <summary>
        /// Handles the OK button's Click event.
        /// </summary>
        /// <param name="sender">The button object.</param>
        /// <param name="e">The event arguments.</param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            _sign    = chkSign.Checked;
            _encrypt = chkEncrypt.Checked;
            switch (cbxSec.SelectedIndex)
            {
            case 0:
                _security = SecurityMode.None;
                break;

            case 1:
                _security = SecurityMode.Explicit;
                break;

            case 2:
                _security = SecurityMode.Implicit;
                break;
            }

            if (txtServer.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please enter SMTP server", "Error");
                return;
            }

            _server = txtServer.Text;

            try
            {
                _timeout = int.Parse(txtTimeout.Text);
            }
            catch (FormatException)
            {
                _timeout = 60000;
                MessageBox.Show("Invalid timeout", "Error");
                return;
            }

            try
            {
                int serverport = int.Parse(txtPort.Text);
                if (serverport < 1 || serverport > 65535)
                {
                    MessageBox.Show("Invalid port, port must be from 1->65535", "Error");
                    return;
                }
                _port = serverport;
            }
            catch (FormatException)
            {
                MessageBox.Show("Invalid port, port must be from 1->65535", "Error");
                return;
            }

            if (txtProxyPort.Text.Length > 0)
            {
                try
                {
                    int pport;
                    pport = int.Parse(txtProxyPort.Text);
                    if (pport < 1 || pport > 65535)
                    {
                        MessageBox.Show("Invalid port number, must be between 1 and 65535");
                        return;
                    }
                    _proxyPort = pport;
                }
                catch (Exception exc)
                {
                    MessageBox.Show("Invalid port: " + exc.Message);
                    return;
                }
            }

            if (txtProxyPassword.Text.Length > 0 && txtProxyUserName.Text.Length == 0)
            {
                MessageBox.Show("Please enter user name");
                return;
            }

            _userName = txtUserName.Text;
            _password = txtPassword.Text;

            _method = (SmtpAuthenticationMethod)cbxMethod.SelectedItem;
            _cert   = txtCertificate.Text;

            _proxyServer = txtProxyHost.Text;
            _proxyType   = (ProxyType)cbxType.SelectedIndex;
            _proxyAuthenticationMethod = (ProxyHttpConnectAuthMethod)cbxProxyMethod.SelectedIndex;
            _proxyUserName             = txtProxyUserName.Text;
            _proxyPassword             = txtProxyPassword.Text;
            _proxyDomain = txtProxyDomain.Text;

            this.DialogResult = DialogResult.OK;
        }