How to make a part of my email body txt bold in VBA?

peter_z

Board Regular
Joined
Feb 27, 2011
Messages
87
Hey Guys

I have some code making vba send an email via outlook.
The code will add some txt to the body of the email.

I am wondering if anyone knows how to make part of the txt in the body of the email bold?

I want this to be bold:
& vbLf & "Part 2" _

Cheers for your help :)

Code:
Sub SendEmails()
Dim aOutlook As Object
Dim aEmail As Object, x As Long
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Dim lngCount As Long
Dim strDate As Date, strTitle As String, strSource As String, StrOutput As String, strMAgent As String
Dim colAttach As Object
Dim oAttach As Object
 
'set Importance
aEmail.Importance = 2
 
'Set Subject
aEmail.Subject = "Hello"
 
'Set Body for mail
aEmail.Body = "Part 1" _
[B]& vbLf & "Part 2" _[/B]
& vbLf & "Part 3"
 
'Send the email
aEmail.Body = aEmail.Body & strBody _
'return field names to first row of new sheet
rst.MoveNext
Loop
'Set attachment
aEmail.Attachments.Add StrOutput
'Set Recipient
aEmail.Cc = strRecipients
'Send Mail
aEmail.Display
'Pop up msg box advising who the email has been sent to
'MsgBox ("Email Sent to: " & strRecipients)
 
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
You can use the HTMLBody property and then use HTML to format the text - something like this:

Code:
aEmail.htmlBody = "Part 1<br>" _
                    & "<b>Part 2</b><br>" _
                    & "Part 3"

The <br> is the line break tag in HTML and the <b> will bolden the text.


HTH
DK
 
Upvote 0
You can use the HTMLBody property and then use HTML to format the text - something like this:

Code:
aEmail.htmlBody = "Part 1<br>" _
                    & "<b>Part 2</b><br>" _
                    & "Part 3"

The <br> is the line break tag in HTML and the <b> will bolden the text.


HTH
DK
still using it 11 years later :D
 
Upvote 0

Forum statistics

Threads
1,216,558
Messages
6,131,400
Members
449,648
Latest member
kyouryo

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