I checked some posts on formating body of an email in VBA (e.g. How to format email body?, formatting email body using VBA or Bolding Text with VBA) but unfortunately can't solve the problem I'm facing.
I want to format the dynamic cells in the body to be bold
I want the email body to look like that:
Dear User,
The following request is in I8.1 Check Resource Availability:
Test Project
The estimated effort below is called out in the request's ROM (in hours): 10 and duration (in business days): 2 Do you have a named resource I can put in for the effort called out? Please provide me with an update at the earliest
Thank you and best regards,
Team.
This is the code I have for now. It's working but I can't find a way to bold the desired values.
Sub Sendmail()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
For Each cell In Columns("D").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And _
LCase(Cells(cell.Row, "E").Value) <> "0" Then
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = cell.Value
.Subject = "Resources awaiting assignment"
.Body = "Dear "& Cells(cell.Row, "C").Value _
& ", " _
& vbNewLine & vbNewLine & _
"The following request is in I8.1 Check Resource Availability: " _
& vbNewLine & vbNewLine & _
Cells(cell.Row, "A").Value _
& vbNewLine & vbNewLine & _
"The estimated effort below is called out in the request's ROM (in hours): "& Cells(cell.Row, "E").Value _
& _
" and duration (in business days): "& Cells(cell.Row, "F").Value _
& vbNewLine & vbNewLine & _
"Do you have a named resource I can put in for the effort called out? Please provide me with an update at the earliest" _
& vbNewLine & vbNewLine & _
"Thank you and best regards, "& vbNewLine & _
"Team."
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
Can anyone advise on how to format it as desired?
Thanks in advance!