Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to bold a word in an email body

Status
Not open for further replies.

vincent76

Programmer
Oct 23, 2001
8
CA
Hi;

I have an vb program that sends an email using the content of an excell cell. Basically it opens up an excell file and gets the value of a specific cell and puts it in an email body and sends it. What I want to do is scan that cell for certain keywords and make them bold and then send it. So the email receiver when he opens the email he'll see those words in bold.

Any help will be greatly apreciated!
 
what are you using to generate the email?

if you are simply putting a text string in and firing it off then you can't make it bold.

you probably have the option of htmltext in your mailbody.

for example with CDONTS you can say
mail.body =
or
mail.htmlbody =


Then you can markup the body of the email to your hearts content
 
Thanks for your reply, I'm using the outlook object library 10.0 Here's my code:

Sub Button2_Click()

Dim objOutlook As Outlook.Application
Dim objMail As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(olMailItem)
objMail.Recipients.Add "zzzz@zzzzz.com"
objMail.Subject = Workbooks(1).Sheets("Renewal Notice").Cells(1, 2).Value
objMail.BodyFormat = olFormatHTML
objMail.Body = Workbooks(1).Sheets("Renewal Notice").Cells(2, 2).Value
objMail.Send

End Sub

I tried using all the body format and nothing work.. keep in mind That I will parse the Workbooks(1).Sheets("Renewal Notice").Cells(2, 2).Value first and bold some words.

Any help ill be grealy apreciated.

Thanks
 
You'll need to send HTML as the body of the email. I suppose it could be as simple as

<HTML>
<BODY>
The word <B>Bold</B> will be bold face.
</BODY>
</HTML>

Although, it seems most email clients recognize html when they see it, you should indicate something like

text/html; charset=&quot;DEFAULT_CHARSET&quot;

in the ContentType header.
Does the Outlook object let you customize all of your headers?
 
Thanks for your reply Schroeder; I don't know if you could modify the headers in the outlook object. I tried putting in the cell for the email body <b>word</b> it didn't do it.. It put literally the bold tags instead of bolding the word when I received the email.
 
don't think you will need to do that

try this

objMail.HTMLBody = Workbooks(1).Sheets(&quot;Renewal Notice&quot;).Cells(2, 2).Value
 
jeepxo's solution looks to be more appropriate for where you're coming from. I don't know anything about the Outlook object.
For mine, if you're going to explicitly put HTML tags in the body of your message, you're going to need to go all out and make a complete HTML document out of it - including the <HTML> declaration at the top as well as altering the ContentType header to tell the recipient's email client how to handle the message.

I suspect this &quot;objMail.HTMLBody&quot; property takes care of writing the HTML and altering the headers for you.
 
Thank you all for your replies, I will try it out tonight and I'll let you know id it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top