Forgot Password

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Amrit Patel
    New Member
    • Mar 2008
    • 1

    Forgot Password

    Hi There,
    I have a login form which includes Username, Password and Email Id.
    If user forgots its password then user should get the password through email.
    Can anyone help me?

    Thanx in advance
  • Semajthewise
    New Member
    • Nov 2007
    • 38

    #2
    Originally posted by Amrit Patel
    Hi There,
    I have a login form which includes Username, Password and Email Id.
    If user forgots its password then user should get the password through email.
    Can anyone help me?

    Thanx in advance

    Look at the tip o the week by Frinny he has an article on sending E-Mails via VB


    hope this helps

    Comment

    • parshupooja
      New Member
      • Jun 2007
      • 159

      #3
      try this, it works
      Code:
      protected void Submit_Click(object sender, EventArgs e)
          {
              string FieldRepId = UserName.Text;
              bool result = SendEmail(userid);
              if (result == true)
                  Response.Redirect("Default.aspx");
              else UserName.Text = "";
              lblStatus.Visible = true;
              lblStatus.Text = "Error Sending Email.";
      
          }
          private bool SendEmail(string userid)
          {      string query = "GetEmail";
              string connectionString = (string)ConfigurationManager.ConnectionStrings["Euro_FieldRep"].ConnectionString;
              SqlConnection myConnection = new SqlConnection(connectionString);
              SqlCommand myCommand = new SqlCommand(query, myConnection);
      
              myCommand.CommandType = CommandType.StoredProcedure;
              myCommand.Parameters.AddWithValue("@userid", userid);
          if (myConnection.State!=ConnectionState.Open) { myConnection.Open(); }
                     try
              {
              if (myConnection.State != ConnectionState.Open) { myConnection.Open(); }
      
               IDataReader drEmailReader = myCommand.ExecuteReader();
      
              while (drEmailReader.Read())
              {
                  string email = drEmailReader[0].ToString().Trim();
                  string password = drEmailReader["password"].ToString();
                  string message = string.Format(" Your password is {0} . This is automatic Reply, Please do not reply ", password);
      
                  Utilities.SendMail("noreply@xxx.com", email, "", "password recovery", message);
                  lblStatus.Text = "Mail has Been sent sucessfully.";
      
              }
                        return true;
          }
          catch (Exception ex)
          {
              return false;
              lblStatus.Text = "Error Sending Email.";
          }
      
          }
      Originally posted by Amrit Patel
      Hi There,
      I have a login form which includes Username, Password and Email Id.
      If user forgots its password then user should get the password through email.
      Can anyone help me?

      Thanx in advance

      Comment

      Working...