Hi :)
I have had good luck creating a VBA script that creates and sends an email using outlook. I just want to know how to add html tags to this. I tried a few methods I found online but nothing has worked. I think the issue is I don't know the correct reference to add. Here is some code similar to what I'm using.
Private Sub Email_Click()
Dim db As Database, rec As Recordset
Dim objoutlook As New Outlook.Application
Dim objMessage As MailItem
Dim strsql As String, strOrder As String, stritems As String
Dim intrecords As Integer, strMessage As String
Set db = CurrentDb()
Set rec = db.OpenRecordset("recordset")
strsql = "SELECT * FROM Table WHERE date = Date()"
While Not rec.EOF
strOrder = "Data: " & vbTab & vbTab & vbTab & vbTab & rec("test") & vbCrLf & "test1: " & vbTab & rec("test1") & vbCrLf & _
"test2: " & vbTab & vbTab & vbTab & vbTab & rec("test2") & vbCrLf & vbCrLf
strBody = strBody & strOrder
rec.MoveNext
strHeader = "This is a test" & vbCrLf & vbCrLf & _
"Your Data: " & vbCrLf & vbCrLf
strMessage = strHeader & strBody
Wend
Set objMessage = objoutlook.CreateItem(olMailItem)
With objMessage
.To = "
[email protected]"
.Subject = "Test"
.Body = strMessage
.Send
End With
rec.Close
Set rec = Nothing
Set objoutlook = Nothing
Set objMessage = Nothing
End Sub