Turn .BODY subject body in outlook into HTMLBODY using VBA

nealmaher

New Member
Joined
Dec 15, 2023
Messages
7
Office Version
  1. 2010
Platform
  1. Windows
Hi Excel Badasses,



The below code which works well to generate the email alerts on the 90th day anniversary of the hire date. BUT, the only thing I need help with is the “subject body”

I want to turn the outlook email subject body into HTMLBODY so I can bold the cell values to distinguish from the rest of the script. I don’t know how to do that!

Currently I have it in regular body as you can see in the highlighted orange below.

Could someone please help me turn it into HTMLBODY mode .

**Please note that I bolded where it needs to be bolded.

Thanks for the help!


Sub datemudit()

Dim MYAPP As Outlook.Application, MYMAIL As Outlook.MailItem

Dim mydate1 As Date

Dim mydate2 As Long

Dim datetoday1 As Date

Dim datetoday2 As Long

Dim x As Long

lastrow = Sheets("sheet1").Cells(Rows.Count, 1).End(xlUp).Row

For x = 6 To lastrow

mydate1 = Cells(x, 8).Value

mydate2 = mydate1

Cells(x, 15).Value = mydate2

datetoday1 = Date

datetoday2 = datetoday1

Cells(x, 16).Value = datetoday2

'If mydate2 - datetoday2 >= 90 Then

If datetoday2 - mydate2 = 90 Then


Set MYAPP = New Outlook.Application

Set MYMAIL = MYAPP.CreateItem(olMailItem)

MYMAIL.To = Cells(x, 11).Value & ";" & Cells(x, 12).Value

With MYMAIL

.Subject = "Employee Referral Bonus Award" & "-" & Cells(x, 1).Value


'.Body = "Dear " & Cells(x, 10).Value & "," & vbCrLf & vbCrLf & "Hope you are doing well!" & vbCrLf & vbCrLf & "This is to notify you that employee " & Cells(x, 1).Value & " is now eligible to recieve a referral bonus award in the amount of " & Cells(x, 6).Value & " " & Cells(x, 7).Value & vbCrLf & Cells(x, 1).Value & " is being rewarded for referring candidate " & Cells(x, 2).Value & " for the position of " & Cells(x, 3).Value & " in the " & Cells(x, 5).Value & " location." & vbCrLf & "Please coordinate with your local Payroll department to process this award payment for the next payroll cycle" & "." & vbCrLf & vbCrLf & "Please reply back if you have any questions" & "." & vbCrLf & vbCrLf & "Sincerely,"

.Display

'.Send

End With

Cells(x, 13) = "Yes"

Cells(x, 13).Font.ColorIndex = 21

Cells(x, 13).Font.Bold = True


'Cells(x, 13).Value = mydate2 - datetoday2

Cells(x, 14).Value = datetoday2 - mydate2

End If

Next

Set MYAPP = Nothing

Set MYMAIL = Nothing

MsgBox " Code Excecuted!"
End Sub
 
Sorry about the cross posting. I didn't know the rules. This is my first time .
Won't happen again
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,215,069
Messages
6,122,954
Members
449,095
Latest member
nmaske

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