邮箱接收随机验证码

邮箱接收随机验证码

页面效果
邮箱接收随机验证码_第1张图片
邮箱接收随机验证码_第2张图片

前台代码:

  

点击按钮事件:

protected void Button1_Click(object sender, EventArgs e)
{
       SmtpClient client = new SmtpClient("smtp.qq.com", 465/587);
    Random Rdm = new Random();
    //产生0到100000的随机数
    int iRdm = Rdm.Next(00000, 999999);
    MailMessage msg = new MailMessage("A", "B", "cyrus", iRdm.ToString());
    client.UseDefaultCredentials = false;
    System.Net.NetworkCredential basicAuthenticationInfo =
     new System.Net.NetworkCredential("A", "C");
    client.Credentials = basicAuthenticationInfo;
    client.EnableSsl = true;
    client.Send(msg);

}

邮箱接收随机验证码_第3张图片
邮箱接收随机验证码_第4张图片

你可能感兴趣的:(代码记录,邮箱接收随机验证码)