+ Reply to Thread
Results 1 to 3 of 3

How to handle font style in email body via VBA

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    How to handle font style in email body via VBA

    Hi everyone,

    I am building a macro to send out mails with specific content.

    One portion of the mail content would be in Bulletin Points. Example -

    ________________________________________
    Usage Policy:
    Why we do this…
    • First point.
    • Second point.
    • Third point.
    Terms & conditions:
    • First point.
    • Second point.
    • Third point.
    ________________________________________

    I couldnt get the right format in the body of the code.
    Could someone please help.

    My code :

        Dim OutApp As Object
        Dim Itm As Object
    
        Set OutApp = CreateObject("Outlook.Application")
        Set Itm = OutApp.CreateItem(0)
    
              With Itm
                    .To = "[email protected]"
                    .Subject = "Subject"
                    .Body = "Txt"   ' (Bulletin Points should go here)
                    .Send 
                End With

  2. #2
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How to handle font style in email body via VBA

    You need to use the .HtmlBody property instead of just .Body then you use standard html to get what you want:

    HTML Code: 

  3. #3
    Forum Contributor
    Join Date
    11-29-2012
    Location
    Coimbatore, India
    MS-Off Ver
    Excel 2010
    Posts
    101

    Re: How to handle font style in email body via VBA

    Hi thank you for the response.
    But when I use .HTMLBody I couldnt bring the hyperlink of an excel cell to the body of e- mail

    For example consider i am taking the hyperlink from a cell in a variable - strbody1

    strbody1 = Cells(cell.Row, "E").Hyperlinks(1).Address

    and when I use this inside .HTMLBody, hyperlink is not displaying in the e-mail. I am getting blank output in the e-mail

        Dim OutApp As Object
        Dim Itm As Object
    
        Set OutApp = CreateObject("Outlook.Application")
        Set Itm = OutApp.CreateItem(0)
    
        strbody1 = Cells(cell.Row, "E").Hyperlinks(1).Address
    
              With Itm
                    .To = "[email protected]"
                    .Subject = "Subject"
                    .HTMLBody = strbody1  
                    .Send 
                End With
    I think i should use <a> </a> for hyperlink. But I couldnt use it as I will taking the hyperlink from a cell value and not a direct link

    can you please help me on this.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Setting a substitute font for a VBA created Email if recipient doesn't have the body font
    By WiliamsRenault in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-25-2014, 05:10 AM
  2. Change font, color, and style with strbody in Email message
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-22-2014, 04:18 PM
  3. Retain the colors and different style in Body of email
    By gujugolf in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-09-2013, 08:46 PM
  4. Replies: 1
    Last Post: 11-01-2012, 05:29 PM
  5. Replies: 4
    Last Post: 02-27-2012, 03:13 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1