Sure, I don't have outlook installed I'm using the browser control, but look at this code:
Code:
Option Compare Database
Option Explicit
Private doc As Object, head As Object, body As Object, _
table As Object, tr As Object, th As Object, td As Object
Private Sub btnAddTable_Click()
Dim row As Long, col As Long
Set table = doc.createElement("table")
table.Style.Width = "100%"
table.Style.borderCollapse = "collapse"
table.Style.margin = "5px"
body.appendChild table
' Create the table rows and columns
For row = 1 To 2
Set tr = doc.createElement("tr")
table.appendChild tr
For col = 1 To 3
Set td = doc.createElement("td")
td.innerText = "Row " & row & ", Column " & col
td.Style.border = "1px solid f2f2f2"
td.Style.backgroundColor = "c5c5c5"
td.Style.Color = "333"
tr.appendChild td
Next col
Next row
' Display the HTML output
Me.txtOutput = doc.documentElement.outerHTML
End Sub
Private Sub btnHtmlDoc_Click()
Me.txtOutput = doc.documentElement.outerHTML
End Sub
Private Sub Form_Open(Cancel As Integer)
Me.WebBrowser0.ControlSource = "=""about:blank"""
End Sub
Private Sub WebBrowser0_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If Me.WebBrowser0.ReadyState = acComplete Then
Set doc = Me.WebBrowser0.Object.Document
Set head = doc.head
Set body = doc.body
End If
End Sub
As you can see, since it's the browser control, first I set it to a blank page to obtain a blank document. Once the browser is fully loaded, it sets the doc variable to the browser's automation document and also gets the head and the body because when a document starts, it comes like this: <html><head></head><body></body></html>. Then, with the buttons we can perform actions on the browser using the doc variable previously set.
I'm basically creating the same table whenever I click and the html code is shown in the textbox. To create the elements it's just a matter of appending children to the parent element. That takes care of the opening and closing of tags. And you can see I'm also adding attributes.
This works with Access 2016, it may not be the same for other versions, because they're constantly changing things, but I hope you get the idea. If you're going to build an email, it's just a matter of creating the document, automating it and then outputting the html to the .HTMLBody property of it, as OP shows in his code. But take a look at the properties of the email, maybe there's a way to attach the object itself instead of the innerHTML text. Either way, it should work.
I'm using a late bound method but you can add a reference to Microsoft HTML Object Library to work with intellisense.