Setting html Text Font in Email Body in VBA

justinMEEE

New Member
Joined
Feb 20, 2018
Messages
1
I have a VBA script in an excel file that will generate an email.
My problem is setting the font in the email.

This code works:
Code:
strbody = "****** style=font-size:11pt;font-family:Arial>Hello.</BODY>"

This code does not work:
Code:
strbody = "****** style=font-size:11pt;font-family:Segoe UI Symbol>Hello.</BODY>"

The only different is the font-family now has spaces in its name.

How do I choose fonts with spaces in their names?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Like this:

Code:
' Outlook module
Sub CreateHTMLMail()
Dim olApp As Outlook.Application, objMail As MailItem, strbody$
Set olApp = Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
strbody = "[SIZE=3]" & _
"Text Line 1" & "
" & "Text Line 2" & "[/SIZE]"
With objMail
    .BodyFormat = olFormatHTML
    .HTMLBody = "******>My text" & strbody
    .Display
End With
End Sub


edit: The forum software interpreted the tags…
 
Last edited:
Upvote 0
Put single quotes (apostrophes) around the style attribute:
Code:
style='font-size:11pt;font-family:Segoe UI Symbol'
 
Upvote 0
This is what I was trying to post:

72k3jix.jpg
 
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,217
Members
449,074
Latest member
cancansova

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