-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForgotpassword.aspx.cs
More file actions
77 lines (68 loc) · 2.71 KB
/
Forgotpassword.aspx.cs
File metadata and controls
77 lines (68 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PassportBusiness;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using PassportBusiness;
using System.Text;
using System.Net;
using System.Net.Mail;
public partial class Forgotpassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bind_Post();
}
}
private void bind_Post()
{
}
protected void btnprint_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["HPSCDBNEW"].ConnectionString);
cn.Open();
String sqlaadhar = "select RegestrationNumber,Email_field,Password from ApplicantDetails where RegestrationNumber=@RegestrationNumber";
SqlCommand cmdaadhar = new SqlCommand(sqlaadhar, cn);
cmdaadhar.Parameters.AddWithValue("@RegestrationNumber", txtRegno.Text.Trim());
SqlDataAdapter daaadhar = new SqlDataAdapter(cmdaadhar);
DataSet dsaadhar = new DataSet();
daaadhar.Fill(dsaadhar);
if (dsaadhar.Tables[0].Rows.Count > 0)
{
try
{
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress("hsrlmonline@gmail.com");
// Recipient e-mail address.
Msg.To.Add(dsaadhar.Tables[0].Rows[0]["Email_field"].ToString());
Msg.Subject = "You have been registered for the online application";
Msg.Body = "Your Registration number is " + dsaadhar.Tables[0].Rows[0]["RegestrationNumber"].ToString() + " and Password is " + dsaadhar.Tables[0].Rows[0]["Password"].ToString();
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("hsrlmonline@gmail.com", "hsrlm@123");
smtp.EnableSsl = true;
smtp.Send(Msg);
Msg = null;
lblmsg.Text = "Email Send to your registered Email Id. Please go to the login page and register again <a href = 'HomePage.aspx' target=_blank>Click Here</a>" ;
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
else
{
lblmsg.Text = "Your Registration Number is not valid";
}
}
}