Consulting

Results 1 to 4 of 4

Thread: Font Properties in an E-mail Body using VBA

  1. #1

    Font Properties in an E-mail Body using VBA

    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

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Ross,

    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:[VBA]
    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
    [/VBA]

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    VBAX Regular
    Joined
    May 2005
    Posts
    12
    Location
    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.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    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

    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •