VBA HTMLBody with String not working.

BrainDiseasee

New Member
Joined
Aug 30, 2023
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am trying to write a code that will send an email with a specified body as a string in this code its dim as strbody and i want the the HTMLBODY to include my outlook signature. I can only get on or the other to work but never both at the same time. The code sample below is just displaying an email with my HTML outlook signature but not the strbody.

Sub SendStatus()

Dim OutApp As Object
Dim Outmail As Object
Dim strbody As String
Dim name As String
Dim status As String
Dim Email As String
Dim Project As String
Dim Tollgate As String
Dim ws As Worksheet
' With Application
' .EnableEvents = False
' .ScreenUpdating = False
' End With
Set OutApp = CreateObject("Outlook.Application")
Set Outmail = OutApp.CreateItem(0)
Set ws = ActiveSheet

Project = ws.Cells(21, 3).Text
name = ws.Cells(39, 8).Text
Email = ws.Cells(39, 9).Text

strbody = "Hello" & Project & ", <p> Project Status has been updated."

On Error Resume Next

With Outmail
.to = Email
.CC = ""
.BCC = ""
.Subject = "Project Status Update: " & Project & " " & Format(Date, "mm-dd-yy")

.HTMLBody = strbody & .HTMLBody
.Display


End With
On Error GoTo 0

Set Outmail = Nothing
Set OutApp = Nothing






End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,223,884
Messages
6,175,174
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top