-
Notifications
You must be signed in to change notification settings - Fork 0
/
forget_college.aspx.cs
63 lines (60 loc) · 2.37 KB
/
forget_college.aspx.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Net.Mail;
using System.Data;
public partial class forget_college : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit1_Click(object sender, EventArgs e)
{
try
{
DataSet ds1 = new DataSet();
using (SqlConnection con = new SqlConnection("Data Source=AKKI-PC\\SATYAMMSSQL;Initial Catalog=CIS;Integrated Security=True"))
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT [collegeid],[collegepass] FROM college Where [CollegeMail]= '" + txtEmail1.Text.Trim() + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds1);
con.Close();
}
if (ds1.Tables[0].Rows.Count > 0)
{
MailMessage Msg = new MailMessage();
// Sender e-mail address.
Msg.From = new MailAddress(txtEmail1.Text);
// Recipient e-mail address.
Msg.To.Add(txtEmail1.Text);
Msg.Subject = "Your Password Details";
Msg.Body = "Hi, <br/>Please check your Login Detailss<br/><br/>Your CollegeId: " + ds1.Tables[0].Rows[0]["collegeid"] + "<br/><br/>College Password: " + ds1.Tables[0].Rows[0]["collegepass"] + "<br/><br/>";
Msg.IsBodyHtml = true;
// your remote SMTP server IP.
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("er.satyam.don@gmail.com", "15061994");
smtp.EnableSsl = true;
smtp.Send(Msg);
//Msg = null;
lbltxt1.Text = "Your Password Details Sent to your mail";
// Clear the textbox valuess
txtEmail1.Text = "";
}
else
{
lbltxt1.Text = "The Email you entered not exists.";
}
}
catch (Exception ex)
{
Console.WriteLine("{0} Exception caught.", ex);
}
}
}