Making certain words bold and italicized in the body of the text of an email vba

lharr28

New Member
Joined
May 22, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I'm trying to figure out how to make certain words in the body of a text bold and/or italicized.

For instance I have a sentence, "Your bill is past due." I want to make the past due bold.

Here's the code:

Sub EmailAspdf()

Dim EApp As Object
Set EApp = CreateObject("Outlook.Application")

Dim EItem As Object
Set EItem = EApp.CreateItem(0)

With EItem
.To = Range("D10")
.Subject = reportname & " " & "-" & " " & month & " " & fy
.Body = "Hello " & cardholder & "," & vbCrLf _
& vbCrLf _
& "This is notice that you currently have a past due amount on your Corporate Card. Please review the attached report for details. Notify me of your plan of action to resolve this issue by close of business, on " _
& vbCrLf _
& vbCrLf _
& "If these items have already been processed, please disregard this notice." _
& vbCrLf _
& vbCrLf _
& "Warm regards,"

.Attachments.Add (path & fname & ".pdf")
.Display

End With


End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Welcome to the board,

To embolden text you would look to use HTMLbody rather than body. You would need to change the vb commands to HTML. An example is shown below (Remove the speech Marks " " as this is allows me to show the HTML tags).

"<p> write your text</p>"
"<br> this adds a line break <br>"
"<b> this means start bold, after your text add </b>" this ends the bold. Whole example:

"<p><b>This text is bold</b></p>"
 
Upvote 0
Welcome to the board,

To embolden text you would look to use HTMLbody rather than body. You would need to change the vb commands to HTML. An example is shown below (Remove the speech Marks " " as this is allows me to show the HTML tags).

"<p> write your text</p>"
"<br> this adds a line break <br>"
"<b> this means start bold, after your text add </b>" this ends the bold. Whole example:

"<p><b>This text is bold</b></p>"
Thanks Trevor! As you know I'm new to all of this so I'm figuring things out as I got. I tried your suggestion and switched the .Body to >HTMLBody and added <br> for the breaks but when I ran it, it said variable not defined for br. Is there anyway you can copy the code I have and just added in the HTML information. I've tried several times with no luck :(
 
Upvote 0
Try adjusting the HTMLBody as follows:

VBA Code:
.HTMLBody = "Hello<br>" _
& "This is notice that you currently have a <b>past due amount on your Corporate Card</b>. Please review the attached report for details. Notify me of your plan of action to resolve this issue by close of business, on<br>" _
& "<p>If these items have already been processed, please disregard this notice.</P>" _
& "<p></P>" _
& "<p>Warm regards,</P>"
 
Upvote 0

Forum statistics

Threads
1,217,383
Messages
6,136,267
Members
450,001
Latest member
KWeekley08

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