0% found this document useful (0 votes)
4 views2 pages

Sendd

The document contains a code snippet for a button click event that retrieves user details from a MySQL database based on email and security number inputs. If a matching user is found, it sends an email containing the username and password to the specified email address using SMTP. The code includes error handling for database connection and email sending processes.

Uploaded by

lkishomy02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Sendd

The document contains a code snippet for a button click event that retrieves user details from a MySQL database based on email and security number inputs. If a matching user is found, it sends an email containing the username and password to the specified email address using SMTP. The code includes error handling for database connection and email sending processes.

Uploaded by

lkishomy02
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Protected Sub Button4_Click(ByVal sender As Object, ByVal e As System.

EventArgs)
Handles Button4.Click
02
Dim mailtxt As String = mail_txt.Text
03
Dim numtxt As String = num_txt.Text
04
Dim sbmail As New StringBuilder
05
Dim conn As New MySqlConnection("DataBase=sample;Data
source=localhost;username=root;password=sa;")
06
Dim str As String
07
str = " select * from user_details where email='" + mail_txt.Text + "' and
secno='" + num_txt.Text + "' "
08
Dim cmd As New MySqlCommand(str, conn)
09
conn.Open()
10
Dim dr As MySqlDataReader = cmd.ExecuteReader()
11
dr.Read()
12
Dim userID As New Integer
13
If dr.HasRows Then
14
Dim dbuname As String = dr("user_name").ToString()
15
Dim dbpassword As String = dr("user_password").ToString()
16
Dim dbemail As String = dr("email").ToString()
17
Dim dbnum As String = dr("secno").ToString()
18

19
If ((String.Equals(mailtxt, dbemail)) And (String.Equals(numtxt, dbnum)))
Then
20
Dim MailMsg As New MailMessage()
21
MailMsg.To.Add("mail_txt.Text".ToString())
22
MailMsg.From = New MailAddress("[email protected]")
23
MailMsg.Subject = "Retrive Your Password"
24
Dim body As String = ("username=" + dbuname + " " + "password=" + dbpassword
+ " " + "mailid=" + dbemail + " ")
25
MailMsg.Body = body.ToString()
26
MailMsg.IsBodyHtml = True
27
Dim SmtpMail As New SmtpClient()
28
SmtpMail.Host = "smtp.gmail.com"
29
SmtpMail.Port = 587
30
SmtpMail.Credentials = New System.Net.NetworkCredential("anub96",
"capricorn")
31
SmtpMail.EnableSsl = True
32
SmtpMail.Send(MailMsg)
33
End If

You might also like