Пример #1
0
 private void timer2_Tick(object sender, EventArgs e)
 {
     if (seconds2 == 0)
     {
         timer2.Stop();
         //旧的验证码过期,生成一个新的验证码
         strMailVeriCode = MailVeriCodeClass.CreateRandomMailCode(6);
     }
 }
Пример #2
0
        private void link_VerificationCode_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string recEMailAddress = txt_QQMail.Text.Trim();

            strMailVeriCode = MailVeriCodeClass.CreateRandomMailCode(6);
            string strBody              = $"验证码:{strMailVeriCode},5分钟内有效,请勿泄漏于他人。如非本人操作,请忽略。系统邮件请勿回复!";
            string strSubject           = "崔杰【科技】";            //邮件标题
            string strMyEmailAddress    = "*****@*****.**"; //发件人邮箱
            string strAuthorizationCode = "lssukrgcortkdijj";  //邮箱授权码

            //判断是否输入了邮箱
            if (string.IsNullOrEmpty(recEMailAddress))
            {
                MessageBox.Show("请输入邮箱!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_QQMail.Focus();
            }
            else if (MailVeriCodeClass.CheckMail(recEMailAddress) == false)
            {
                MessageBox.Show("您输入的QQ邮箱有误,请重新输入!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                txt_QQMail.Focus();
                return;
            }
            else
            {
                if (MailVeriCodeClass.SendMailMessage(strMyEmailAddress, recEMailAddress, strSubject, strBody, strAuthorizationCode) == true)
                {
                    link_VerificationCode.Enabled = false;
                    timer1.Interval = 1000;
                    timer1.Start();
                    timer2.Interval = 1000;
                    timer2.Start();
                }
                else
                {
                    txt_QQMail.Focus();
                }
            }
        }