求大神给看看
发不了邮件,求大神看看哪儿有问题
protected void btbConfirm_Click(object sender, EventArgs e)
{
string str1 = "select * from yhxxb where dzyx='" + txtEmail.Text + "' and yhm='" + txtUsername.Text + "'";
if (DataBase.ExecuteRead(str1))
{
SendMessage();
}
else
{
DataBase.AlertMessagge(Page,"",GetType(),"用户名或邮箱错误!");
}
}
public void SendMessage()
{
string sqlcon = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["myConnection"].ConnectionString;
string str1 = "select * from yhxxb where dzyx='" +txtEmail.Text + "' and yhm='" + txtUsername.Text + "'";
SqlConnection con = new SqlConnection(sqlcon);
con.Open();
SqlCommand cmd = new SqlCommand(str1, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
//取数据库中的用户名和密码
string password = dr["mm"].ToString();
string username = dr["yhm"].ToString();
MailMessage mail = new MailMessage("982112101@qq.com","'" + txtEmail.Text.Trim() + "'");
mail.Subject = "找回密码";
mail.Body = "用户您好<br/> 您的用户名为:'" + username + "'<br/> 您的密码为:'" + password + "'<br/> 请妥善保管!";
mail.IsBodyHtml = true; // 是否是HTML格式
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.qq.com";//QQ的SMPT服务器IP
smtp.Port = 25;//SMPT端口号,一般为25
smtp.Credentials = new System.Net.NetworkCredential("982112101@qq.com","321"); //指定登录服务器(即邮箱的帐号和密码)的用户名和密码,注意要在自己邮箱中设置开启SMTP服务