I have created VBA code in Access that takes the contents of a recordset and places the data in the body of an email message. My code looks like this:
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("email@example.com")
objOutlookRecip.Type = olTo
Set objOutlookRecip = .Recipients.Add("firstname.lastname@example.org")
objOutlookRecip.Type = olCC
.Subject = "Something "
Dim rstData As ADODB.Recordset
Set rstData = New ADODB.Recordset
rstData.ActiveConnection = CurrentProject.Connection
rstData.Open "SELECT * FROM qryAny"
Dim strData As String
Do Until rstData.EOF
strData = strData & rstData("FullName") & vbNewLine
.Body = strData
For Each objOutlookRecip In .Recipients
That code all works great. The problem is that I want to output additional fields (not just FullName), and I want the data to appear in a table so that the data is formatted nicely. I have tried separating the fields with tabs, but I have no way of knowing the length of the data in each field, so the data does not line up correctly.
Is this possible? Any help would be much appreciated!