-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmPasswordRecovery.vb
executable file
·66 lines (55 loc) · 2.61 KB
/
frmPasswordRecovery.vb
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
Imports System.Net.Mail
Imports System.Data.oledb
Public Class frmPasswordRecovery
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Cursor = Cursors.WaitCursor
Timer1.Enabled = True
Dim ds As New DataSet()
Dim con As New oledbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\PayrollManagerDB.accdb;Persist Security Info=False;")
con.Open()
Dim cmd As New oledbCommand("SELECT Password FROM Users Where username = 'admin'", con)
Dim da As New oledbDataAdapter(cmd)
da.Fill(ds)
con.Close()
If ds.Tables(0).Rows.Count > 0 Then
Dim Msg As New MailMessage()
' Sender e-mail address.
Msg.From = New MailAddress("[email protected]")
' Recipient e-mail address.
Msg.[To].Add("[email protected]")
Msg.Subject = "Your Password Details"
Msg.Body = "Your Password: " & Convert.ToString(ds.Tables(0).Rows(0)("Password")) & ""
Msg.IsBodyHtml = True
' your remote SMTP server IP.
Dim smtp As New SmtpClient()
smtp.Host = "smtp.gmail.com"
smtp.Port = 587
smtp.Credentials = New System.Net.NetworkCredential("[email protected]", "abcd")
smtp.EnableSsl = True
smtp.Send(Msg)
MessageBox.Show("Password Successfully sent " & vbCrLf & "Please check your mail", "Thank you", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Hide()
frmlogin.Show()
frmlogin.UserName.Text = ""
frmlogin.Password.Text = ""
frmlogin.UserName.Focus()
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Me.Hide()
frmlogin.Show()
frmlogin.UserName.Text = ""
frmlogin.Password.Text = ""
frmlogin.UserName.Focus()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Cursor = Cursors.Default
Timer1.Enabled = False
End Sub
Private Sub frmPasswordRecovery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class