Vinicius
Vinicius

Reputation: 65

how maintain the format in outlook in vba

this a part of my code to send an e-mail by outlook in vba. However, I am want to send with the first sentence in bold. Ex: where I write the text in first body (how I named the cell of each paragraph), I can choose where I want the text be bold, but these format do not remain when the vba create the e-mail

Any idea?

EX: My name is Vinicius. I am from Brazil and like Soccer

enter image description here

    pretit = Sheets(CurrSh).Range("pretit").Value
    midtit = Sheets(CurrSh).Range("midtit").Value
    prebod = Sheets(CurrSh).Range("prebod").Value
    bod = Sheets(CurrSh).Range("bod").Value
    postbod = Sheets(CurrSh).Range("postbod").Value
    body2 = Sheets(CurrSh).Range("body2").Value
    body3 = Sheets(CurrSh).Range("body3").Value
    body4 = Sheets(CurrSh).Range("body4").Value
    report = Sheets(CurrSh).Range("report").Value 

 If Sheets(CurrSh).Range("body4").Value <> vbEmpty Then

                            'Set ObjApp = CreateObject("Outlook.Application")
                            While (Sheets(CurrSh).Range("emailad_ini").Offset(n, 0).Value <> "")
                            emailad = Sheets(CurrSh).Range("emailad_ini").Offset(n, 0).Value
                            firstname = Sheets(CurrSh).Range("firstname_ini").Offset(n, 0).Value


                            Set objMail(n) = ObjApp.CreateItem(0)

                            objMail(n).display
                            objMail(n).To = emailad
                            objMail(n).Subject = pretit & " " & firstname & midtit
                            objMail(n).HtmlBody = "<HTML><BODY><FONT FACE='Arial'><FONT SIZE='2'>" & prebod & " " & firstname & "," & "<br>" & "<br>" & bod & "<br>" & "<br>" & body2 & "<br>" & "<br>" & body3 & "<br>" & "<br>" & body4 & "<br>" & "<br>" & postbod & objMail(n).HtmlBody & "</FONT></FONT></BODY></HTML>"
                            objMail(n).Attachments.Add (report)

Upvotes: 0

Views: 708

Answers (1)

braX
braX

Reputation: 11735

Assuming you are using .HTMLBody you would just enclose everything you want bold in an HTML bold tag like this:

Not Bold <b>This is bold</b> This is no longer bold.

Upvotes: 1

Related Questions