+ Reply to Thread
Results 1 to 3 of 3

Macro E-mail font and font color

  1. #1
    Registered User
    Join Date
    10-07-2014
    Location
    US
    MS-Off Ver
    All
    Posts
    1

    Macro E-mail font and font color

    Hello-

    First time poster. I have a macro that is sending an E-mail out, and it is working well. My only problem that i'm having is in the body of the E-mail i do not know how to configure the macro so that i can change the font, and the font color.
    The part of the Macro i need help changing is:

    strbody = "Hey," & vbNewLine & vbNewLine & _
    "TEXT TEXT TEXT TEXT TEXT." & vbNewLine & _
    "Thanks," & vbNewLine & _
    "Ron Wiesler"


    Here is the entire macro:


    Sub Mail_Every_Worksheet()
    Dim sh As Worksheet
    Dim wb As Workbook
    Dim FileExtStr As String
    Dim FileFormatNum As Long
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String

    strbody = "Hey," & vbNewLine & vbNewLine & _
    "TEXT TEXT TEXT TEXT TEXT." & vbNewLine & _
    "Thanks," & vbNewLine & _
    "Ron Wiesler"

    TempFilePath = Environ$("temp") & "\"

    If Val(Application.Version) < 12 Then
    'You use Excel 97-2003
    FileExtStr = ".xls": FileFormatNum = -4143
    Else
    'You use Excel 2007-2013
    FileExtStr = ".xlsm": FileFormatNum = 52
    End If

    With Application
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    Set OutApp = CreateObject("Outlook.Application")

    For Each sh In ThisWorkbook.Worksheets
    If sh.Range("G2").Value Like "?*@?*.?*" Then

    sh.Copy
    Set wb = ActiveWorkbook

    TempFileName = "Sheet " & sh.Name & " of " _
    & ThisWorkbook.Name & " " & Format(Now, "dd-mmm-yy h-mm-ss")

    Set OutMail = OutApp.CreateItem(0)

    With wb
    .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum

    On Error Resume Next
    With OutMail
    .To = sh.Range("G2").Value
    .CC = sh.Range("I2").Value
    .BCC = ""
    .Subject = "Excel Help"
    .Body = strbody
    .Attachments.Add wb.FullName
    'You can add other files also like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'or use .Display
    End With
    On Error GoTo 0

    .Close savechanges:=False
    End With

    Set OutMail = Nothing

    Kill TempFilePath & TempFileName & FileExtStr

    End If
    Next sh

    Set OutApp = Nothing

    With Application
    .ScreenUpdating = True
    .EnableEvents = True
    End With
    End Sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Macro E-mail font and font color

    See the Use HTMLBody instead of Body section of this link.
    Tips for the Outlook object model examples
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    01-21-2013
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    227

    Re: Macro E-mail font and font color

    Please Login or Register  to view this content.
    Use the code above for font size, color n type.
    If I've been of help, plz add reputation.

+ 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. Replies: 2
    Last Post: 02-04-2013, 02:00 PM
  2. Change font color based on font color of another cell
    By Ibyers in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2012, 09:36 AM
  3. change font color and font style in shape
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-05-2011, 10:05 AM
  4. change e-mail font default color
    By mvan in forum Excel General
    Replies: 1
    Last Post: 04-04-2006, 06:35 PM

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