i use this to create a module in excel for a macro button on the sheet to send an email with html formatting, the dquote is for when it is input into the excel module and the code is converted to text. adjust as required for your situation.
Code:
Dim VBProj As VBIDE.VBProject
Dim VBComp As VBIDE.VBComponent
Set VBProj = Excel_Workbook.VBProject
Set VBComp = VBProj.VBComponents.Add(vbext_ct_StdModule)
Dim CodeMod As VBIDE.CodeModule
Dim CodeMod1 As VBIDE.CodeModule
Dim LineNum As Long
Const DQUOTE = """"
VBComp.Name = "preview"
Set VBComp = VBProj.VBComponents("preview")
Set CodeMod = VBComp.CodeModule
With CodeMod
LineNum = .CountOfLines + 1
.InsertLines LineNum, "Sub print_preview"
LineNum = LineNum + 1
.InsertLines LineNum, "ActiveWorkbook.Worksheets.PrintPreview"
LineNum = LineNum + 1
.InsertLines LineNum, "End Sub"
LineNum = LineNum + 1
.InsertLines LineNum, "Sub Send_Mail"
LineNum = LineNum + 1
.InsertLines LineNum, "Dim OutlookApp As Object"
LineNum = LineNum + 1
.InsertLines LineNum, "Dim OutlookMail As Object"
LineNum = LineNum + 1
.InsertLines LineNum, "Set OutlookApp = CreateObject(" & DQUOTE & "Outlook.Application" & DQUOTE & ")"
LineNum = LineNum + 1
.InsertLines LineNum, "Set OutlookMail = OutlookApp.CreateItem(0)"
LineNum = LineNum + 1
.InsertLines LineNum, "t = ThisWorkbook.FullName"
LineNum = LineNum + 1
.InsertLines LineNum, "With OutlookMail"
LineNum = LineNum + 1
.InsertLines LineNum, "Application.DisplayAlerts = False"
LineNum = LineNum + 1
.InsertLines LineNum, "ActiveWorkbook.Save"
LineNum = LineNum + 1
.InsertLines LineNum, "Application.DisplayAlerts = True"
LineNum = LineNum + 1
.InsertLines LineNum, ".Attachments.Add(t)"
LineNum = LineNum + 1
.InsertLines LineNum, ".Subject = " & DQUOTE & "Employee TimeSheets Workbook" & DQUOTE
LineNum = LineNum + 1
.InsertLines LineNum, ".htmlbody = " & DQUOTE & "<br>" & "Hello," & "<br>" & "<br>" & "The attached Workbook contains " & xxx & " Employee " & _
"timesheet" & xx & " for 07-02-15 to 22-02-15" & _
"<br>" & "<br>" & "<br>" & "<br>" & "Regards," & _
"<br>" & "<br>" & "<br>" & "<img src='" & "c:\aaa\logo.png'" & "height=60 width=210" & ">" & _
"<br>" & "<br>" & "<u>" & "Disclaimer." & "</u>" & "<br>" & _
"The information in this e-mail message and any attached file is strictly confidential."
LineNum = LineNum + 1
.InsertLines LineNum, ".Display"
LineNum = LineNum + 1
.InsertLines LineNum, "End With"
LineNum = LineNum + 1
.InsertLines LineNum, "Set OutlookMail = Nothing"
LineNum = LineNum + 1
.InsertLines LineNum, "Set OutlookApp = Nothing"
LineNum = LineNum + 1
.InsertLines LineNum, "End Sub"
End With