Guest User

Untitled

a guest
Jan 17th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. protected void Buttonpsw_Click(object sender, EventArgs e)
  2. {
  3. string mainconn = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
  4. SqlConnection con = new SqlConnection(mainconn);
  5. string sqlquery = "select Email,Password1 from [dbo].[Users1] where Email =@Email";
  6. SqlCommand sqlcommand = new SqlCommand(sqlquery, con);
  7. sqlcommand.Parameters.AddWithValue("@Email",Textemail.Text);
  8. con.Open();
  9. SqlDataReader sdr = sqlcommand.ExecuteReader();
  10. if (sdr.Read())
  11. {
  12.  
  13. string username = sdr["Email"].ToString();
  14. string Password = sdr["Password1"].ToString();
  15. MailMessage ms = new MailMessage("roqaia.alrfou@gmail.com",Textemail.Text);
  16. ms.Subject = "Your password!";
  17. ms.Body = string.Format("Hello : <h1>{0}</h1> is your Email ID <br/> Your Password is <h1>{1}</h1>",username,Password);
  18. ms.IsBodyHtml = true;
  19. SmtpClient smtp = new SmtpClient();
  20. smtp.Host = "smtp.gmail.com";
  21. smtp.EnableSsl = true;
  22. NetworkCredential nc = new NetworkCredential();
  23. nc.UserName = "roqaia.alrfou@gmail.com";
  24. nc.Password = "133";
  25. smtp.UseDefaultCredentials = true;
  26. smtp.Credentials = nc;
  27. smtp.Port = 587;
  28. smtp.Send(ms);
  29. Labelmsg.Text = "Your Password has been sent to" + Textemail.Text;
  30. Labelmsg.ForeColor = Color.Green;
  31.  
  32.  
  33. }
  34. else
  35. {
  36. Labelmsg.Text = Textemail.Text+" This Email ID isn't Exist! Please sign up";
  37. Labelmsg.ForeColor = Color.Red;
  38.  
  39. }
  40.  
  41. <connectionStrings>
  42. <add name="dbconnection"
  43. connectionString="server= USER-PCSQL;Data
  44. Source=localhost;Initial Catalog=Tracking_System;
  45. Integrated Security=True;Pooling=False
  46. ; Trusted_Connection=True;"
  47. providerName="System.data.sqlclient" />
  48. </connectionStrings>
Add Comment
Please, Sign In to add comment