Hello. I have created a macro to send an email with data from a worksheet. It works fine as plain text but I would like to format (ie bold) the dollar value in (I40) and date value in (I21) which means I need to convert it to HTML. Everything I've tried has failed. Can you please help? This is my code.
>>> use code - tags <<<
>>> use code - tags <<<
Code:
Private Sub CommandButton4_Click()
Dim xOutApp As Object
Dim xOutMail As Object
Dim objFileSystem As Object
Dim strTempFile As String
'Dim myAttachments As Object
Dim xMailBody As String
On Error Resume Next
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hello " & Range("O3") & vbNewLine & vbNewLine & _
"Thank you for providing your documentation." & vbNewLine & vbNewLine & _
"As a result of our review we can confirm that you were impacted by some of the issues and are now owed a gross payment of " & Format(Range("I40"), "Currency") & "." & vbNewLine & _
"This payment will be made to your nominated bank account on " & Range("I21") & "." & vbNewLine & vbNewLine & _
"If you have any further questions please refer to the information on our website." & vbNewLine & vbNewLine & _
"Thank you" & vbNewLine
With xOutMail
.SentOnBehalfOfName = """Project"" <email@email>"
.To = Range("T1")
.CC = ""
.BCC = ""
.Subject = Range("O1")
.Body = xMailBody
.Send 'or use .Display
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Last edited by a moderator: