VBA Sending Email from Excel - Make specific text of email body BOLD

HM996

New Member
Joined
Jul 20, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi, this is actually my first time posting on this site

I am using the vba code below to send out email reminder via outlook. However, I am wondering how to make specific text which is fixed in the code to be bold, as listed : Event/Activity ; Department ; Date of Event ; Description

Can anyone please help me with this? Thanks in advanced.


VBA Code:
Dim wStat As Range, i As Long
Dim dam As Object

For Each wStat In Range("I2", Range("I" & Rows.Count).End(xlUp))
    If wStat.Value = "Overdue" Then
        i = wStat.Row
        Set dam = CreateObject("Outlook.Application").CreateItem(0)
        dam.To = Range("F" & i).Value
        dam.Cc = Range("G" & i).Value
        dam.Subject = Range("C" & i).Value
        dam.htmlBody = "    Hi " & Range("E" & i).Value & "," & vbCr & vbCr & vbCr & _
                   " This is to remind you that the " & Range("C" & wStat.Row).Value & _
                   " is overdue. The details are as follows:" & vbCr & vbCr & _
                   " Event / Activity : " & Range("C" & i).Value & vbCr & vbCr & _
                   " Department : " & Range("D" & i).Value & vbCr & vbCr & _
                   " Date of event : " & Range("A" & i).Value & vbCr & vbCr & _
                   " Description : " & Range("H" & i).Value & vbCr & vbCr & _
                   " Please update your status as soon as possible! Thanks." & vbCr & vbCr & vbCr & _
                   " Best Regards," & vbCr & _
                   " XX Department"
        '
        dam.Display
    End If
Next
MsgBox "Reminder sent"
End Sub
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Code:
dam.htmlBody = "    Hi " & Range("E" & i).Value & "," & vbCr & vbCr & vbCr & _
                   " This is to remind you that the " & Range("C" & wStat.Row).Value & _
                   " is overdue. The details are as follows:" & vbCr & vbCr & _
                   " <B>Event / Activity : " & Range("C" & i).Value & vbCr & vbCr & _    ' here <B> start bolding
                   " Department : " & Range("D" & i).Value & vbCr & vbCr & _
                   " Date of event : " & Range("A" & i).Value & vbCr & vbCr & _
                   " Description : " & Range("H" & i).Value & vbCr & vbCr & _
                   "</B>Please update your status as soon as possible! Thanks." & vbCr & vbCr & vbCr & _    'here </B> stop bolding
                   " Best Regards," & vbCr & _
                   " XX Department"

You have to use HTML tags < B > to switch bolding ON and < /B > to switch bolding OFF
 
Upvote 0
If you are using HTMLBody then you need to use HTML tags throughout the message. vbCr does nothing in .HTMLBody.
Add or remove a <br>tag to increase/decrease the blank lines.

Code:
   Set dam = CreateObject("Outlook.Application").CreateItem(0)
        
        
          MailBody = "<p> Hi " & Range("E" & i).Value & " , <br><br><br>" _
          & "This is to remind you that the " & Range("C" & wStat.Row).Value _
          & "is overdue. The details are as follows: <br><br>" _
          & "<b>Event / Activity :</b> " & Range("C" & i).Value & "<br><br>" _
          & "<b>Department :</b> " & Range("D" & i).Value & "<br><br>" _
          & "<b>Date of event :</b> " & Range("A" & i).Value & "<br><br>" _
          & "<b>Description :</b> " & Range("H" & i).Value & "<br><br>" _
          & "Please update your status as soon as possible! Thanks.<br><br><br>" _
          & "Best Regards, <br><br>" _
          & " XX Department </p> "
        
        
        dam.To = Range("F" & i).Value
        dam.Cc = Range("G" & i).Value
        dam.Subject = Range("C" & i).Value
        dam.HtmlBody = MailBody
 
Upvote 0
If you are using HTMLBody then you need to use HTML tags throughout the message. vbCr does nothing in .HTMLBody.
Add or remove a <br>tag to increase/decrease the blank lines.

Code:
   Set dam = CreateObject("Outlook.Application").CreateItem(0)
       
       
          MailBody = "<p> Hi " & Range("E" & i).Value & " , <br><br><br>" _
          & "This is to remind you that the " & Range("C" & wStat.Row).Value _
          & "is overdue. The details are as follows: <br><br>" _
          & "<b>Event / Activity :</b> " & Range("C" & i).Value & "<br><br>" _
          & "<b>Department :</b> " & Range("D" & i).Value & "<br><br>" _
          & "<b>Date of event :</b> " & Range("A" & i).Value & "<br><br>" _
          & "<b>Description :</b> " & Range("H" & i).Value & "<br><br>" _
          & "Please update your status as soon as possible! Thanks.<br><br><br>" _
          & "Best Regards, <br><br>" _
          & " XX Department </p> "
       
       
        dam.To = Range("F" & i).Value
        dam.Cc = Range("G" & i).Value
        dam.Subject = Range("C" & i).Value
        dam.HtmlBody = MailBody
If you are using HTMLBody then you need to use HTML tags throughout the message. vbCr does nothing in .HTMLBody.
Add or remove a <br>tag to increase/decrease the blank lines.

Code:
   Set dam = CreateObject("Outlook.Application").CreateItem(0)
       
       
          MailBody = "<p> Hi " & Range("E" & i).Value & " , <br><br><br>" _
          & "This is to remind you that the " & Range("C" & wStat.Row).Value _
          & "is overdue. The details are as follows: <br><br>" _
          & "<b>Event / Activity :</b> " & Range("C" & i).Value & "<br><br>" _
          & "<b>Department :</b> " & Range("D" & i).Value & "<br><br>" _
          & "<b>Date of event :</b> " & Range("A" & i).Value & "<br><br>" _
          & "<b>Description :</b> " & Range("H" & i).Value & "<br><br>" _
          & "Please update your status as soon as possible! Thanks.<br><br><br>" _
          & "Best Regards, <br><br>" _
          & " XX Department </p> "
       
       
        dam.To = Range("F" & i).Value
        dam.Cc = Range("G" & i).Value
        dam.Subject = Range("C" & i).Value
        dam.HtmlBody = MailBody

It works like a charm! thank you so much for your help!!
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,015
Members
449,060
Latest member
LinusJE

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