can i color specific line in email send by excel

Some videos you may like

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Worf

Well-known Member
Joined
Oct 30, 2011
Messages
3,872
This answers a follow-up question that appeared on the Chandoo thread, how to insert a picture from worksheet to email body:

VBA Code:
Sub ExportPic(fname$)
Dim MyChart$, MyPicture$, PicWidth&, PicHeight&, sr As ShapeRange
Set sr = ActiveSheet.Shapes.Range(Array("imagem 7"))    ' desired picture
Application.ScreenUpdating = False
MyPicture = sr.Name
PicHeight = sr.Height: PicWidth = sr.Width
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
Selection.Border.LineStyle = 0
MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2)
With ActiveSheet
    With .Shapes(MyChart)
        .Width = PicWidth
        .Height = PicHeight
    End With
    .Shapes(MyPicture).Copy
    With ActiveChart
        .ChartArea.Select
        .Paste
    End With
    .ChartObjects(1).Chart.Export Filename:=fname, FilterName:="jpg"
    .Shapes(MyChart).Cut
End With
Application.ScreenUpdating = True
End Sub

Sub mail()
Dim myitem As MailItem, olApp, fname$
fname = "c:\pub\Pic30.jpg"
ExportPic fname                                 ' from sheet to hard disk
Set olApp = CreateObject("Outlook.Application")
Set myitem = olApp.CreateItem(olMailItem)
With myitem
    .To = "nice@educated.com"
    .cc = ""
    .Subject = "Free Help"
    .Attachments.Add fname, 1, 0
    .HTMLBody = "<html><p>Summary of Status.</p>" & _
    "<img src=""cid:" & Split(fname, "\")(2) & """height=520 width=750>"
    .Display
End With
Set myitem = Nothing: Set olApp = Nothing
End Sub
 

Forum statistics

Threads
1,089,646
Messages
5,409,502
Members
403,266
Latest member
HMR120

This Week's Hot Topics

Top