Suppose you have taken a Text Field name as TextBox1 to accepting the Email ID. We need to search the email ID at our Customer table " tblcustomer " and will send the correspondence Password to the Email ID When Some one Click on the " ForgetPwd " Button........
protected void ForgetPwdButton3_Click(object sender, EventArgs e)
{
string id = TextBox1.Text;
string sql = "select password from tblcustomer where customer_email='" + email+ "'";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
// GmailSender gs = new GmailSender();
string pwd = dr[0].ToString();
if (SendMail("sender mail id", "sender pw", id, pwd))
{
Response.Write("<script language='javascript'>alert('Password has been sent to your email ID');</script>");
TextBox1.Text = "";
}
}
else
{
Response.Write("<script language='javascript'>alert('You have Entered wrong email ID');</script>");
}
}
protected void ForgetPwdButton3_Click(object sender, EventArgs e)
{
string id = TextBox1.Text;
string sql = "select password from tblcustomer where customer_email='" + email+ "'";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
// GmailSender gs = new GmailSender();
string pwd = dr[0].ToString();
if (SendMail("sender mail id", "sender pw", id, pwd))
{
Response.Write("<script language='javascript'>alert('Password has been sent to your email ID');</script>");
TextBox1.Text = "";
}
}
else
{
Response.Write("<script language='javascript'>alert('You have Entered wrong email ID');</script>");
}
}