在asp.net中忘记密码C# [英] forget password in asp.net C#
本文介绍了在asp.net中忘记密码C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SMTP服务器需要安全连接,或者客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息
asp.code
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
asp.code
<style type="text/css">
.Button
{
background-color :#FF5A00;
color: #FFFFFF;
font-weight: bold;
margin-right: 2px;
padding: 4px 20px 4px 21px;
}
.auto-style18 {
height: 23px;
width:auto;
border: 2px solid #a1a1a1;
border-radius:5px;
margin-top:200px;
margin-left:300px;
padding-left:0;
margin-bottom:100px;
}
.auto-style19 {
height: 40px;
}
</style>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
<table cellspacing="2" cellpadding="2" border="0" class="auto-style18">
<tr><td></td><td>Forgot Password</td></tr>
<tr><td>Enter Your Email:</td><td><asp:TextBox ID="txtEmail" runat="server" /></td></tr>
<tr><td class="auto-style19"></td><td class="auto-style19"><asp:button ID="btnSubmit" Text="Submit" runat="server" CssClass="Button" OnClick="btnSubmit_Click"/></td></tr>
<tr><td colspan="2" style=" color:red"><asp:Label ID="lbltxt" runat="server"/></td></tr>
</table>
</div>
C#代码
C# code
try
{
SqlConnection con = new SqlConnection("**********");
ds = new DataSet();
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT username,password FROM getezee Where mail= '" + txtEmail.Text.Trim() + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
con.Close();
}
if (ds.Tables[0].Rows.Count > 0)
{
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress("getezee.social@gmail.com");
// Recipient e-mail address.
Msg.To.Add(txtEmail.Text);
Msg.Subject = "Your Password Details";
Msg.Body = "Hi, <br />Please check your Login Detailss<br /><br />Your Username: " + ds.Tables[0].Rows[0]["username"] + "<br /><br />Your Password: " + ds.Tables[0].Rows[0]["password"] + "<br /><br />";
Msg.IsBodyHtml = true;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.Credentials = new NetworkCredential("social@gmail.com", "*****");
smtp.Send(Msg);
//Msg = null;
lbltxt.Text = "Your Password Details Sent to your mail";
// Clear the textbox valuess
txtEmail.Text = "";
}
else
{
lbltxt.Text = "The Email you entered not exists.";
}
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex); /// error came here
}
推荐答案
检查以下答案
当您尝试从不同的时区/ IP /计算机登录时,通常会发生这种情况 [ ^ ]
这篇关于在asp.net中忘记密码C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文