Insert a table in the Body of Email from Access using HTML

I'm using the code below to generate emails from Access and I would like to insert an Access table in the body of the email. Can you give me example code to accomplish. Thanks


Dim objOutlook As Object, objEmailMessage As Object
Dim sSubj As String, sBody As String, sTo As String, strCC As String

Dim rs As dao.Recordset
Set rs = CurrentDb.OpenRecordset("tbl­_FDA_No_Sig")

Do Until rs.EOF
     sMail = sMail & ";" & rs("email")
    rs.MoveNext
Loop

sMail = MID(sMail, 2)





Set objOutlook = CreateObject("Outlook.Application")
Set objEmailMessage = objOutlook.CreateItem(0)

With objEmailMessage
         .To = sMail
         If strCC & "" <> "" Then
                    .CC = strCC
         End If
         .Subject = sSubj
     

'Set body format to HTML
.BodyFormat = olFormatHTML
'.To = "Your Mail"
 .CC = "xxx@cdc.gov"
.Subject = "ISAs/MOUs Expected Signatures Dates"
 .HTMLBody = "The OFSPO Team would like to follow up with you regarding the status of the following outstanding ISAs:."
 

     
     
     
     
      .Display
      '      .send
End With


End Sub
shieldscoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
You open a recordset and loop through it:

Dim rst as DAO.Recordset
Set rst = Currentdb.OpenRecordset("SELECT blah blah FROM MyTable")

<other code here>

Dim sBody As String
Do Until rst.EOF
  sBody = sBody & "<tr><td>" & rst("Field1") & "</td><td>" & rst("Field2") & "</td></tr>"
  rst.MoveNext
Loop

sBody = "The OFSPO Team would like to follow up with you regarding the status of the following outstanding ISAs:<br><br><table>" &  sBody & "</table>"
.HTMLBody = sBody

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shieldscoAuthor Commented:
Thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.