Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
DoCmd.SendObject , , , "some.ones@email.address", , , "your subject", sBodyText
Private Sub cmdSend_Click
Dim r As DAO.Recordset
Dim sBodyText As String
Set r = Me.RecordsetClone
sBodyText = "Field 1" & vbTab & "Field 2" & vbCrLf
While Not r.EOF
sBodyText = sBodyText & r.Fields(0) & vbTab & r.Fields(1) & vbTab & vbCrLf
r.MoveNext
Wend
r.Close
DoCmd.SendObject , , , "some.ones@email.address", , , "your subject", sBodyText
End Sub
Sub testBuildBody()
Dim rst As DAO.Recordset
Dim sBodyText As String
[COLOR=green]' open the query named Crew_selection as a recordset[/color]
Set rst = CurrentDb.OpenRecordset("Crew_Selection", dbOpenSnapshot)
[COLOR=green]' set some headers[/color]
sBodyText = "ID" & vbTab & "NAME" & "NATIONALITY" & vbCrLf
[COLOR=green]' loop through the recordset, adding each row as a new line (vbcrlf adds a new line feed)[/color]
While Not rst.EOF [COLOR=green]'.eof is end of file[/color]
sBodyText = sBodyText & rst.Fields("ID") & vbTab & rst.Fields("Name") & vbTab & rst.Fields("NATIONALITY") & vbCrLf
rst.MoveNext
Wend
[COLOR=green]' print to the immediate window[/color]
Debug.Print sBodyText
rst.Close [COLOR=green]' close recordset[/color]
[COLOR=green]' rest of code to send goes here[/color]
End Sub