Reputation: 31
I need to format the specific String value which was acquired from Excel in Outlook.
Once the value is provided by Excel, macro will then append that value in the email message.
I tried testing and setting the value to BOLD but all of the contents of the message became BOLD. How do I format the value in such a way I can use the font type, size and color to my liking?
obj.HTMLBody = "<b>" & StrAgnt & vbCrLf & obj.HTMLBody
Upvotes: 2
Views: 3091
Reputation: 12495
See Working with Outlook HTMLBody
Option Explicit
Sub CreateHTMLMail()
'Creates a new e-mail item and modifies its properties.
Dim olApp As Outlook.Application
Dim objMail As Outlook.MailItem
Set olApp = Outlook.Application
'Create e-mail item
Set objMail = olApp.CreateItem(olMailItem)
Dim StrAgnt As String
StrAgnt = "<HTML><H2>The body HTML.</H2><BODY>Type the message text here. </BODY></HTML>" & vbCrLf & vbCrLf & _
"<P><FONT FACE=""Comic Sans MS"" size=""6"" color=""red""><B>TEST.</B></FONTt></P>" & vbCrLf & vbCrLf & _
"<P><FONT FACE=""Times New Roman"" size=""4"" color=""blue""><i>TEST</i></FONT></P>" & vbCrLf & vbCrLf & _
"<P><FONT FACE=""Arial"" size=""3"" color=""green"">TEST</FONT></P>" & vbCrLf & vbCrLf
With objMail
'Set body format to HTML
.BodyFormat = olFormatHTML
.HTMLBody = StrAgnt
.Display
End With
End Sub
MSDN HTMLBody Property
Upvotes: 1