Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void Buttonpsw_Click(object sender, EventArgs e)
- {
- string mainconn = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;
- SqlConnection con = new SqlConnection(mainconn);
- string sqlquery = "select Email,Password1 from [dbo].[Users1] where Email =@Email";
- SqlCommand sqlcommand = new SqlCommand(sqlquery, con);
- sqlcommand.Parameters.AddWithValue("@Email",Textemail.Text);
- con.Open();
- SqlDataReader sdr = sqlcommand.ExecuteReader();
- if (sdr.Read())
- {
- string username = sdr["Email"].ToString();
- string Password = sdr["Password1"].ToString();
- MailMessage ms = new MailMessage("roqaia.alrfou@gmail.com",Textemail.Text);
- ms.Subject = "Your password!";
- ms.Body = string.Format("Hello : <h1>{0}</h1> is your Email ID <br/> Your Password is <h1>{1}</h1>",username,Password);
- ms.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.EnableSsl = true;
- NetworkCredential nc = new NetworkCredential();
- nc.UserName = "roqaia.alrfou@gmail.com";
- nc.Password = "133";
- smtp.UseDefaultCredentials = true;
- smtp.Credentials = nc;
- smtp.Port = 587;
- smtp.Send(ms);
- Labelmsg.Text = "Your Password has been sent to" + Textemail.Text;
- Labelmsg.ForeColor = Color.Green;
- }
- else
- {
- Labelmsg.Text = Textemail.Text+" This Email ID isn't Exist! Please sign up";
- Labelmsg.ForeColor = Color.Red;
- }
- <connectionStrings>
- <add name="dbconnection"
- connectionString="server= USER-PCSQL;Data
- Source=localhost;Initial Catalog=Tracking_System;
- Integrated Security=True;Pooling=False
- ; Trusted_Connection=True;"
- providerName="System.data.sqlclient" />
- </connectionStrings>
Add Comment
Please, Sign In to add comment