SQLConn = " your connection string "
query = "select Password,email from logininfo where login_name='" + loginname + "'";
SQLDA = new SqlDataAdapter(query, SQLConn);
forgotds= new DataSet();
SQLDA.Fill(forgotds);
rowcount = forgotds.Tables[0].Rows.Count;
if(rowcount>0)
{
email = forgotds.Tables[0].Rows[0]["email"].ToString();
password = forgotds.Tables[0].Rows[0]["password"].ToString();
try
{
MailMessage mail = new MailMessage();
mail.From = "from address";
mail.To = email;
mail.Subject = "Reg. Password ";
mail.Body = " Your Password for the user" + " "+ txtLoginName.Text.ToString() + " " + " is " + password;
SmtpMail.SmtpServer = "server ip address or Name";
SmtpMail.Send(mail);
lblmessage.Text = " The password has successfully sent to " + email;
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
else
{
lblmessage.Text = " The login " + txtLoginName.Text + " is invalid ";
}
}
Akbar Jinna
reddysankark-13471, if this helps please login to Mark As Answer. | Alert Moderator