Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Net.Mail;
- using System.Net;
- public partial class ForgetPassword : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string username = "";
- string password = "";
- SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
- SqlCommand cmd = new SqlCommand("select username, password from session_login where username=@username", con);
- cmd.Parameters.AddWithValue("@username", txtemail.Text);
- con.Open();
- using (SqlDataReader sdr = cmd.ExecuteReader())
- {
- if (sdr.Read())
- {
- username = sdr["username"].ToString();
- password = sdr["password"].ToString();
- MailMessage mm = new MailMessage("your email", txtemail.Text);
- mm.Subject = "Just Use For Demo!";
- mm.Body = string.Format("Hello: Your Password No is <h1>{0}</h1><br/> ", password);
- mm.IsBodyHtml = true;
- SmtpClient smtp = new SmtpClient();
- smtp.Host = "smtp.gmail.com";
- smtp.EnableSsl = true;
- NetworkCredential nc = new NetworkCredential();
- nc.UserName = "your email";
- nc.Password = "Your password";
- smtp.UseDefaultCredentials = true;
- smtp.Credentials = nc;
- smtp.Port = 25;
- smtp.Send(mm);
- }
- }
- con.Close();
- }
- protected void linkforget(object sender, EventArgs e)
- {
- Response.Redirect("ForgetPassword.aspx");
- }
- }
Add Comment
Please, Sign In to add comment