PDA

View Full Version : Font Properties in an E-mail Body using VBA



rsilberfarb
06-08-2005, 10:16 PM
All,

I am trying to format an e-mail that is created using VBA in Excel. After much research I was able to figure out how to insert carriage returns in the mail, but I can't find where add formating the mail (make some part a bigger font then others and perhaps bold).

Any help is appreciated.

Thanks in Advance,

Ross

MOS MASTER
06-09-2005, 10:21 AM
Hi Ross, :yes

To format an email you can use the "HTMLBody" Property.

Which alows you to write a full HTML mail with all the benifits and downfall's that come with it.

Small example you can execute right away:
Sub SendHTMLMail()
Dim oItem As Outlook.MailItem

Set oItem = Application.CreateItem(olMailItem)

With oItem
.Subject = "Test HTML Mail for VBAX"
.HTMLBody = _
"<html><b><font face=Verdana><font size=2><p>Test Text and Image</p>" & _
"</size></font></b><img src=http://www.vbaexpress.com/images/vbaxlogo.gif " & _
"height=136 width=213</html>"
.Display
End With

Set oItem = Nothing
End Sub


Enjoy! :whistle:

se4mo2
06-09-2005, 08:36 PM
hi saw this thread, just asking how do i attach a picture file inside my local disk such as C:\Program Files\abc.bmp into an email and send it out?

I tried

strPath = Chr(34) & "C:\Program Files\text.bmp" & Chr(34)
With objMsg
.Subject = "Re: " & strSubj
.To = strRcpt
.HTMLBody = _
"<html><font face=Verdana><font size=2><p>Hello Everyone</p>" &_
"</size></font><img src =" & strPath & "></html>"

End With

but it just sends the image as a refernce, meaning if the file is not found on the HDD of the reciever, it doesnt get shown.

MOS MASTER
06-11-2005, 11:39 AM
Hi, :yes

That's true but that's what I intended with a HTML mail.

If you need it to always stick to the email then adapt code from this article: Click here (http://www.outlookcode.com/d/code/htmlimg.htm)

Enjoy! :whistle: