protected void Button2_Click(object sender, EventArgs e) { rs.get_username = TextBox3.Text; rs.get_email = TextBox4.Text; int i = rs.pwd_recovery(); if (TextBox3.Text != "" & TextBox4.Text != "") { if (i == 2) { Page.ClientScript.RegisterStartupScript(this.GetType(), "aa", ""); } else { recovery2(); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "aa", ""); } } public void recovery2() { rs.get_username = TextBox3.Text; rs.get_email = TextBox4.Text; DataSet ds = rs.get_pwd(); if (ds.Tables[0].Rows.Count != 0) { Label2.Text = ds.Tables[0].Rows[0]["u_name"].ToString(); Label3.Text = ds.Tables[0].Rows[0]["pwd"].ToString(); Label4.Text = ds.Tables[0].Rows[0]["mailid"].ToString(); } try { SmtpClient smclient = new SmtpClient(); MailMessage message = new MailMessage(); try { MailAddress fromaddress = new MailAddress("arpita@yahoo.com", ""); smclient.Host = "photo48"; smclient.Port = 25; message.From = fromaddress; message.To.Add(TextBox4.Text); message.Subject = "Password Recovery"; message.IsBodyHtml = true; string body=("u_name=" + Label2.Text+ "pwd=" +Label3.Text+ "mailid=" + Label4.Text + " "); message.Body = body; smclient.Send(message); Page.ClientScript.RegisterStartupScript(this.GetType(), "msg", ""); } catch(SmtpException ex) { } } catch(Exception e) { } }