Hello Guys,
I am trying to create a email with the body showing all of the person's information. I think I made a mess because not Access is stuck. Here is the code.
I am trying to create a email with the body showing all of the person's information. I think I made a mess because not Access is stuck. Here is the code.
Code:
Private Sub cmdEmail_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sqlStr As String
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
'Open the Recordset
Set db = CurrentDb
sqlStr = "SELECT [Employee],FName, FirstName,[State],RegistrationNo,DateExpires FROM QryPERenew WHERE [Employee]='" & Me.cboFName.Column(0) & "'"
Set rs = db.OpenRecordset(sqlStr)
'Create Email
Set oEmail = oApp.CreateItem(olMailItem)
With oEmail
.To = Me.cboEmail
.CC = "...."
.Subject = "Expiring/Expired PE Licensing Renewals - " & rs!FName & Date
Do While Not rs.EOF
rs.MoveFirst
rs.MoveNext
.Body = "Hi " & rs!FirstName & "," & vbNewLine & _
"You have and Expiring/Expired PE license on file. " & _
"Please notify us of your intent to renew or not renew with new expiration date(s). " & vbNewLine & _
"State " & "Expiration Date" & vbNewLine & _
rs!State & " " & rs!DateExpires
Loop
.Display
End With
Set rs = Nothing
Set db = Nothing
End Sub