Option Compare Database
Option Explicit
Private Sub cmd_email_Click()
If (IsNull(Me.cmbEmail)) Then
MsgBox "Please enter Email address"
Exit Sub
End If
Dim db As Database
Dim st As String
Dim rs As dao.Recordset
Dim strHTMLBody As String
Dim Password As Integer
Set db = CurrentDb
st = "select * from tblUser where txtEmailAddress = '" & cmbEmail & "'"
Set rs = CurrentDb.OpenRecordset(st, dbOpenSnapshot)
Password = rs!Password
MsgBox "You will receive your Previous Password in your mailBox"
'save the entered email in a variable
'Status rs!Password
'MsgBox rs!FName
'Do While Not rs.EOF
' DataString = ""
' For Each fld In rs.Fields
' If DataString = "" Then
' DataString = fld.Value
' Password = DataString
' Exit Do
' Else
' DataString = DataString & Chr(9) & fld.Value
' End If
' Next fld
'
' 'MsgBox "" & DataString & ""
' rs.MoveNext
' Loop
'
Dim oApp As Outlook.Application
Dim oMail As MailItem
Set oApp = CreateObject("Outlook.application")
Set oMail = oApp.CreateItem(olMailItem)
oMail.Body = "Your Password"
strHTMLBody = strHTMLBody & "Password: " & Password & "<br/>"
'strHTMLBody = strHTMLBody & "Sent Date: " & date & "<br/><br/>"
oMail.Subject = "Here is Your Previous Password"
oMail.To = rs!txtEmailAddress
oMail.Send
Set oMail = Nothing
Set oApp = Nothing
db.Close
rs.Close
End Sub