+ Reply to Thread
Results 1 to 7 of 7

Making different font sizes or colors within an email body

  1. #1
    Registered User
    Join Date
    02-20-2019
    Location
    Santa Barbara, CA
    MS-Off Ver
    Windows 10 Pro
    Posts
    20

    Making different font sizes or colors within an email body

    Hello,

    I am trying to change the color and font size for different lines within the body of an email generated by VB script in a spreadsheet. For example I want the first line to be Red text, and the very last line (a disclaimer) to be a small font
    My code is below and an example of the desired output is attached.

    Thanks!
    Tim

    Dim RSMMail As Object
    Dim IndRSMMail As Object

    Sheets("EmailList").Select
    Range("A2").Select

    Dim X As Integer
    X = 2

    Do While Cells(X, 1) <> ""

    Set RSMMail = CreateObject("Outlook.Application")
    Set IndRSMMail = RSMMail.CreateItem(olMailItem)

    With IndRSMMail
    .To = Cells(X, 1).Value
    .Subject = "RSM Status " & FullDate
    .attachments.Add "C:\Users\fred\ Reports\RSM Daily " & FullDate & ".pdf"
    .Body = "REPORT RSM's" & vbCrLf & _
    "" & vbCrLf & _
    "Dear " & Cells(X, 2) & "," & vbCrLf & _
    "" & vbCrLf & _
    "Attached you will find today's Report" & vbCrLf & _
    "" & vbCrLf & _
    "Thanks & vbCrLf & _
    " " & vbCrLf & _
    " " & vbCrLf & _
    "The Team" & vbCrLf & _
    " " & vbCrLf & _
    " " & vbCrLf & _
    " " & vbCrLf & _
    "This email message is a private communication. The information transmitted, including attachments Thank you." & vbCrLf & _
    .Display

    X = X + 1

    End With

    Loop


    Output example attached

  2. #2
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Making different font sizes or colors within an email body

    The most common method is to use .htmlBody rather than .Body. Code in html syntax or code to a worksheet range and convert that to html. Ron de Bruin has a routine to do the later. http://www.rondebruin.nl/win/s1/outlook/bmail2.htm

  3. #3
    Registered User
    Join Date
    02-20-2019
    Location
    Santa Barbara, CA
    MS-Off Ver
    Windows 10 Pro
    Posts
    20

    Re: Making different font sizes or colors within an email body

    Hi Ron,
    Thanks for the quick reply.
    I looked at the Rob de Bruin page and it looks like it applies to changing the font parameters from the spreadsheet output. I have the spreadsheet all formatted, I .pdf it and then attach it to an email, and I just need to play with the font parameters in the body of the email on different lines in the email. All the text in the body of the email is generated in VB, while the spreadsheet is all in the attached .pdf.

    i.e. I want to make this line red
    .Body = "REPORT RSM's" & vbCrLf & _

    I want to make this line small font.
    "This email message is a private communication. The information transmitted, including attachments Thank you." & vbCrLf & _

    Thanks,

    Tim

  4. #4
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Making different font sizes or colors within an email body

    I am not Ron.

    You will not achieve your goal using .Body method. That is why I gave you other solutions.

    So, I gave you 2 solutions using .htmlBody method. You chose not to use Ron's RangetoHTML() method. The easier method then would be to construct the string for htmlBody using html syntax as I explained. If you need examples of html syntax, here is one site. https://www.w3docs.com/learn-html/html-font-tag.html

    A 3rd solution is possible but I don't want to confuse you too much.

    A 4th solution might be to use Ron's method to use your Outlook signature. Most would put what you want in that. If no pics in signature, this simple example should suffice.
    Please Login or Register  to view this content.
    Last edited by Kenneth Hobson; 03-17-2021 at 03:29 PM.

  5. #5
    Registered User
    Join Date
    02-20-2019
    Location
    Santa Barbara, CA
    MS-Off Ver
    Windows 10 Pro
    Posts
    20

    Re: Making different font sizes or colors within an email body

    Hi Kenneth,
    Sorry about the name, just had Ron on my mind from reading him post.
    I think I'm getting it now, I went through Ron's post again and it's making sense. Your additional example is very helpful. It looks like I am on the right track now.

    Appreciate your help!

    Be well

    Tim

  6. #6
    Forum Expert Kenneth Hobson's Avatar
    Join Date
    02-05-2007
    Location
    Tecumseh, OK
    MS-Off Ver
    Office 365, Win10Home
    Posts
    2,573

    Re: Making different font sizes or colors within an email body

    No problem, glad it helped. Due to html in this example, I had to attach the short example file.

  7. #7
    Registered User
    Join Date
    02-20-2019
    Location
    Santa Barbara, CA
    MS-Off Ver
    Windows 10 Pro
    Posts
    20

    Re: Making different font sizes or colors within an email body

    Thanks for the additional attachment, I have all working perfectly now - thank you!!

+ 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. increase the font size of a variable in the body of email
    By NeoDasari in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-26-2015, 05:11 PM
  2. VBA to adjust font in body of email and add signature to email
    By jawirth44 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-14-2015, 08:39 PM
  3. How to handle font style in email body via VBA
    By sugaprasad in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2015, 08:55 AM
  4. 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
  5. 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
  6. Replies: 1
    Last Post: 11-01-2012, 05:29 PM
  7. Replies: 4
    Last Post: 02-27-2012, 03:13 AM

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