本文介绍了当tyr发送电子邮件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
发送电子邮件时出错
SqlConnection scon_forgott =
new SqlConnection( ConfigurationManager.ConnectionStrings [ MyConnectionString]。ToString());
scon_forgott.Open();
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter( select *来自tbl_Users,其中Email =' + a.Text + ',
scon_forgott);
da.Fill(dt);
if (dt.Rows.Count > 0 )
{
string newpass = Guid.NewGuid()。ToString();
string hashPass = FormsAuthentication.HashPasswordForStoringInConfigFile(newpass, MD5跨度>);
Classes.Users clsUsers = new Classes.Users();
DataSet ds = clsUsers.SelectRow_User(dt.Rows [ 0 ] [ 用户名跨度>]的ToString());
DataRow drRow = ds.Tables [ tbl_Users]。行[ 0 跨度>];
clsUsers.updatePasswordNew( int .Parse(drRow [ ID]。ToString()),hashPass);
MailMessage mail = new MailMessage();
mail.From = new MailAddress( [email protected]跨度>);
mail.To.Add( new MailAddress(drRow [ 电子邮件跨度>]的ToString()))。
mail.Subject = subjectttttt;
mail.Body = booooooooodddddyyyyyyyyy;
mail.IsBodyHtml = true ;
SmtpClient smtp = new SmtpClient( smpt .mydomains.com跨度>);
smtp.Credentials = new NetworkCredential( [email protected], bIXSg1a8);
smtp.EnableSsl = false ;
smtp.Send(mail);
Label lbl = LoginView1.FindControl( lblError) as 标签;
lbl.ForeColor = Color.ForestGreen;
lbl.Text = 发送新通行证;
}
else
{
Label lbl = LoginView1.FindControl( lblError) as 标签;
lbl.ForeColor = Color.Red;
lbl.Text = 找不到用户;
}
和我的错误
连接尝试失败,因为已连接派对在一段时间后没有正确回复,或者建立连接失败,因为连接主机...
如何解决它。
解决方案
i have a error when send email
SqlConnection scon_forgott = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ToString()); scon_forgott.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter("select * from tbl_Users where Email='" + a.Text + "'", scon_forgott); da.Fill(dt); if (dt.Rows.Count > 0) { string newpass = Guid.NewGuid().ToString(); string hashPass = FormsAuthentication.HashPasswordForStoringInConfigFile(newpass, "MD5"); Classes.Users clsUsers = new Classes.Users(); DataSet ds = clsUsers.SelectRow_User(dt.Rows[0]["UserName"].ToString()); DataRow drRow = ds.Tables["tbl_Users"].Rows[0]; clsUsers.updatePasswordNew(int.Parse(drRow["ID"].ToString()), hashPass); MailMessage mail = new MailMessage(); mail.From = new MailAddress("[email protected]"); mail.To.Add(new MailAddress(drRow["Email"].ToString())); mail.Subject = "subjectttttt"; mail.Body ="booooooooodddddyyyyyyyyy"; mail.IsBodyHtml = true; SmtpClient smtp = new SmtpClient("smpt.mydomains.com"); smtp.Credentials = new NetworkCredential("[email protected]", "bIXSg1a8"); smtp.EnableSsl = false; smtp.Send(mail); Label lbl = LoginView1.FindControl("lblError") as Label; lbl.ForeColor = Color.ForestGreen; lbl.Text ="send new pass"; } else { Label lbl = LoginView1.FindControl("lblError") as Label; lbl.ForeColor = Color.Red; lbl.Text = "user not found"; }
and my error
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host ...
how to resolve it.
解决方案
这篇关于当tyr发送电子邮件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!