HI, need help please. I currently have a form with below code that puts records generated from a search into the body of an email. The problem with below code is the table with the record is not in proper tabular format. Can someone please let me know what i need to add to the code or if certain parts need to be re-arranged to get this. Many thanks for the help.
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim olItem As Variant
Dim olMailItem As Variant
Dim olApp As Object
Dim sTable As String
sTable = "<HTML><Body><table border='2'"
Set olApp = CreateObject("outlook.application")
Set olItem = olApp.CreateItem(olMailItem)
olItem.To = "email address"
olItem.cc = "email address"
olItem.Subject = "Confirmation"
olItem.HTMLBody = "<html><font face=calibri>" & "Please confirm" & "<br>" & _
"<br>" & _
"or i will kick you" & "<br>" & _
"<br>"
olItem.Display
Set db = CurrentDb
Set rec = Me.RecordsetClone
With rec
If Not (rec.BOF And rec.EOF) Then
rec.MoveLast
rec.MoveFirst
intCount = rec.RecordCount
For intLoop = 1 To intCount
olItem.HTMLBody = olItem.HTMLBody & sTable & "<tr><td>" & rec("ContractNo") & "</td><td>" & rec("ClientName") & "</td><td>" & rec("RateSet Date") & "</td><td>" & rec("Pay/Rec") & "</td><td>" & rec("Currency") & "</td><td>" & Format(rec("Amount") & "</td></tr>", "$#,##0.00") & "<br>" & _
"<br>"
rec.MoveNext
Next intLoop
End If
End With
Set olApp = Nothing
Set olItem = Nothing
End Sub
Dim db As DAO.Database
Dim rec As DAO.Recordset
Dim olItem As Variant
Dim olMailItem As Variant
Dim olApp As Object
Dim sTable As String
sTable = "<HTML><Body><table border='2'"
Set olApp = CreateObject("outlook.application")
Set olItem = olApp.CreateItem(olMailItem)
olItem.To = "email address"
olItem.cc = "email address"
olItem.Subject = "Confirmation"
olItem.HTMLBody = "<html><font face=calibri>" & "Please confirm" & "<br>" & _
"<br>" & _
"or i will kick you" & "<br>" & _
"<br>"
olItem.Display
Set db = CurrentDb
Set rec = Me.RecordsetClone
With rec
If Not (rec.BOF And rec.EOF) Then
rec.MoveLast
rec.MoveFirst
intCount = rec.RecordCount
For intLoop = 1 To intCount
olItem.HTMLBody = olItem.HTMLBody & sTable & "<tr><td>" & rec("ContractNo") & "</td><td>" & rec("ClientName") & "</td><td>" & rec("RateSet Date") & "</td><td>" & rec("Pay/Rec") & "</td><td>" & rec("Currency") & "</td><td>" & Format(rec("Amount") & "</td></tr>", "$#,##0.00") & "<br>" & _
"<br>"
rec.MoveNext
Next intLoop
End If
End With
Set olApp = Nothing
Set olItem = Nothing
End Sub