Excel VBA Building an HTML body for an emal

Posted on 2014-04-07
Last Modified: 2014-04-11
I have started using the following code to build an HTML body for an email
How do I change Font color and do a line return?

oMsg.HTMLBody = "<html><body>My Body</body></html>"
oMsg.BodyFormat = 2
Question by:Murray Brown
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 39

Assisted Solution

by:Pratima Pharande
Pratima Pharande earned 125 total points
ID: 39985204
Try this

oMsg.HTMLBody = "<html><body><font size=3  color=red>My Body </font></body></html>"
LVL 52

Assisted Solution

Rgonzo1971 earned 125 total points
ID: 39985233

pls try

oMsg.HTMLBody = "<html><body><font size=3  color=red>My <br>Body </font></body></html>"

Open in new window

LVL 36

Assisted Solution

Kimputer earned 125 total points
ID: 39985295
For different sizes, colors and line returns:

oMsg.HTMLBody = "<html><body><font size=3  color=red>line 1</font><br><font size=2  color=blue>line 2</font><br><font size=1  color=green>line 3 </font><br></body></html>"
LVL 27

Accepted Solution

MacroShadow earned 125 total points
ID: 39985357
There are many WYSIWYG free  online html editors, you design the text as you like and it returns the html.¿

Author Closing Comment

by:Murray Brown
ID: 39995375

Featured Post

Want Experts Exchange at your fingertips?

With Experts Exchange’s latest app release, you can now experience our most recent features, updates, and the same community interface while on-the-go. Download our latest app release at the Android or Apple stores today!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question