Results 1 to 4 of 4
  1. #1
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128

    Unhappy code not sending password in the email

    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

  2. #2
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    I'm assuming you want strHTMLBody to end up in the body of the e-mail? Your code doesn't actually attach it to the body. Perhaps it should look something like this?
    Code:
    strHTMLBody = "<p>Your Password</p>"
    strHTMLBody = strHTMLBody & "Password: " & Password & "<br/>"
    strHTMLBody = strHTMLBody & "Sent Date: " & Date & "<br/><br/>"
    oMail.Body = strHTMLBody
    oMail.Subject = "Here is Your Previous Password"
    oMail.To = rs!txtEmailAddress
    oMail.Send

  3. #3
    jj1 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2014
    Posts
    128
    Thanks it worked

  4. #4
    thebigthing313 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2014
    Posts
    119
    Sure thing! Good luck with the rest of your project!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 03-26-2014, 10:04 AM
  2. Sending A Report Via Email
    By Ka-Tet in forum Reports
    Replies: 0
    Last Post: 09-02-2013, 09:18 AM
  3. Email sending
    By Steven.Allman in forum Access
    Replies: 25
    Last Post: 06-21-2010, 09:37 AM
  4. Sending email
    By nashr1928 in forum Reports
    Replies: 8
    Last Post: 04-27-2010, 11:14 PM
  5. VB code for sending email through Option Group?
    By getdpt in forum Programming
    Replies: 0
    Last Post: 08-23-2009, 03:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums