With the below function, I am able to paste the query in the email body without any issue, but I need to add column heads and gridlines around the query result, they are missing. Please help.
Thank you.
Public Function SubmitInternal() As Boolean
Dim DbsLCA As DAO.Database
Dim RSTLca As Recordset
Dim StrBody As String
Dim AddrTo As String
Dim strSubject As String
Dim LCAcc As String
On Error GoTo errorhandler
Set DbsLCA = CurrentDb()
Set RSTLca = DbsLCA.OpenRecordset("SubmittedQry")
AddrTo = "recipients@mail.com"
LCAcc = "NIV@mail.com"
strSubject = "List of cases Submitted today"
StrBody = "Hi," & vbNewLine & vbNewLine
StrBody = StrBody & "These are the cases submitted today." & vbNewLine & vbNewLine
'StrBody = StrBody & "Regards," & vbNewLine & vbNewLine
StrBody = StrLCABody & "Team." & vbNewLine & vbNewLine & vbNewLine & vbNewLine
If RSTLca.RecordCount <> 0 Then
RSTLca.MoveLast
RSTLca.MoveFirst
Do While Not RSTLca.EOF
StrBody = StrBody & RSTLca.Fields("Employeeid") & " " & " " & " " & " " & RSTLca.Fields("Givenname") & " " & " " & " " & " " & RSTLca.Fields("Lastname") & " " & " " & " " & "-" & " " & " " & " " & " " & " " & RSTLca.Fields("LCANumber") & vbNewLine
RSTLca.MoveNext
Loop
End If
DoCmd.SendObject to:=AddrTo, outputformat:=acFormatSNP, cc:=LCAcc, subject:=strSubject, Messagetext:=StrBody
errorhandler:
MsgBox (Err.Description)
Cancel = True
End Function
Thank you.
Public Function SubmitInternal() As Boolean
Dim DbsLCA As DAO.Database
Dim RSTLca As Recordset
Dim StrBody As String
Dim AddrTo As String
Dim strSubject As String
Dim LCAcc As String
On Error GoTo errorhandler
Set DbsLCA = CurrentDb()
Set RSTLca = DbsLCA.OpenRecordset("SubmittedQry")
AddrTo = "recipients@mail.com"
LCAcc = "NIV@mail.com"
strSubject = "List of cases Submitted today"
StrBody = "Hi," & vbNewLine & vbNewLine
StrBody = StrBody & "These are the cases submitted today." & vbNewLine & vbNewLine
'StrBody = StrBody & "Regards," & vbNewLine & vbNewLine
StrBody = StrLCABody & "Team." & vbNewLine & vbNewLine & vbNewLine & vbNewLine
If RSTLca.RecordCount <> 0 Then
RSTLca.MoveLast
RSTLca.MoveFirst
Do While Not RSTLca.EOF
StrBody = StrBody & RSTLca.Fields("Employeeid") & " " & " " & " " & " " & RSTLca.Fields("Givenname") & " " & " " & " " & " " & RSTLca.Fields("Lastname") & " " & " " & " " & "-" & " " & " " & " " & " " & " " & RSTLca.Fields("LCANumber") & vbNewLine
RSTLca.MoveNext
Loop
End If
DoCmd.SendObject to:=AddrTo, outputformat:=acFormatSNP, cc:=LCAcc, subject:=strSubject, Messagetext:=StrBody
errorhandler:
MsgBox (Err.Description)
Cancel = True
End Function