Esempio n. 1
0
        /// <summary>
        /// 解析帐号信息
        /// </summary>
        public static string GetAccount(HttpSessionState session)
        {
            string account = "";

            if (session["Account"] == null || session["Account"].Equals(""))
            {
                account = "";
            }
            else
            {
                account = session["Account"] as string;
                account = Locker.Decrypt(account, "UserInfo");
            }
            return(account);
        }
Esempio n. 2
0
        /// <summary>
        /// 解析密码信息
        /// </summary>
        public static string GetPassword(HttpSessionState session)
        {
            string account  = GetAccount(session);
            string password = "";

            if (session["Password"] == null || session["Password"].Equals("") || account.Equals(""))
            {
                password = "";
            }
            else
            {
                password = session["Password"] as string;
                password = Locker.Decrypt(password, account);
            }
            return(password);
        }
Esempio n. 3
0
        /// <summary>
        /// 发送邮件
        /// </summary>
        protected void Button_send_Click(object sender, EventArgs e)
        {
            if (from.Equals(""))
            {
                from = TextBox_from.Text;
            }
            if (psw.Equals(""))
            {
                psw = TextBox_psw.Text;
            }
            if (psw.StartsWith(EncryptHead))
            {
                psw = Locker.Decrypt(psw.Substring(EncryptHead.Length), TextBox_from.Text);                               // 对密码信息进行解密
            }
            if (to.Equals(""))
            {
                to = TextBox_to.Text;
            }
            if (subject.Equals(""))
            {
                subject = TextBox_subject.Text;
            }
            if (subject.Equals(""))
            {
                subject = DateTime.Now.ToString();
            }

            if (body.Equals(""))
            {
                body = TextBox_body.Text;
            }


            if (!check())
            {
                return;                         // 输入信息格式不正确
            }
            bool isSp = CheckBox_sp.Checked;    // 单独发送


            bool sendResult = true;

            if (!isSp)
            {
                if (!sendEmail(from, psw, to, subject, body, attch))
                {
                    sendResult = false;
                }
            }
            else
            {
                foreach (string str0 in to.Split(';'))
                {
                    string str = str0.Trim();
                    if (!str.Equals(""))
                    {
                        if (!sendEmail(from, psw, to, subject, body, attch))
                        {
                            sendResult = false;
                        }
                    }
                }
            }
            Label_TipInfo.Text = sendResult ? "邮件发送成功" : ("邮件发送失败 -> " + errorInfo);

            // 记录邮件信息
            string info = "from=" + from + "&psw=" + TextBox_psw.Text + "&to=" + to + "&subject=" + subject + "&body=" + body + "&attch=" + attch + "";

            log.WriteLine(info);

            if (sendResult)
            {
                // 清空已发送信息
                to      = TextBox_to.Text = "";
                subject = TextBox_subject.Text = "";
                body    = TextBox_body.Text = "";
            }
        }