Give the below function, I'd like to have the variable %TABLE_HERE%
replaced with a table generated from the range of the Excel Spreadsheet that is also attached to the email.
Public Function GenerateEmail(fileName As String, tbleRange As Range)
Application.ScreenUpdating = False
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItemFromTemplate(fileName)
With OutMail
.HTMLbody = Replace(OutMail.HTMLbody, "%TABLE_HERE%", RangetoHTML(tbleRange))
.Attachments.Add (Application.ActiveWorkbook.FullName)
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Function
I did a bit of research and came across a great function that will do all this for you and wanted to share it with everyone here! Please refer to my answer below
Website I got it from here...