Hi Arun,
Replace your code with this that should do what you wanted and also fix the problem with the Signature you reported in the other Thread.
I removed all the Font settings and put the info directly in the Body.
I left a diffrent font setting for the Signature that you can see how to format individual text different if neccessary
to change the Background or text put new colorcodes in this line Color is textcolor and background-color is obviously background color
Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"
Sub Button1_Click()
Dim ce As Range, i As Long
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String, strcc As String, strbcc As String
Dim strsub As String, strbody As String
'c01 = "C:\Users\12453\Documents\Testing\ABJ\AAA.xlsm" 'change the path and the file name
For i = 2 To Sheets("Sheet1").Range("a65536").End(xlUp).Row
If Cells(i, 1).Value <> "" Then
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
With Sheets("Sheet1")
strto = .Cells(i, 4).Value
strcc = .Cells(i, 5).Value
strbcc = ""
strsub = "Welcome to the Project " & " " & .Cells(i, 2)
Picturepath = "C:\Users\12453\Desktop\download.jpg" '<-- add path to image here
End With
Stylebody = "<BODY style=font-size:10pt;font-family:Arial;color:rgb(255,255,0);background-color:rgb(79,129,189)>"
closing = "</BODY>"
With OutMail
.BodyFormat = 2
.To = strto
.cc = strcc
.bcc = strbcc
.Subject = strsub
.SentOnBehalfOfName = "kaiserOps2@cognizant.com"
.Attachments.Add Picturepath, olByValue
.htmlbody = Stylebody & "<ol><li> Welcome to the Project" & " " & Sheet1.Cells(i, 2) & _
"</li></br>" & "Hi there," & "<br/>" & "We welcome you all to the project" & " " & Sheet1.Cells(i, 2).Value & _
"<br>" & "<br><li><B>Embedded Image:</B></li></ol><br>" & _
"<div style='margin-left:200px;'><img src='cid:download.jpg'" & "width='800' height='200'><br></div>" & _
"<font face=""Arial"" size=""2"" color=""White"">" & "<br>Best Regards, <br>Arun.SJ</font></span>" & closing 'To add a sentence with project name as in the excel - Welcome to the Project " & " " & Sheet1.Cells(i, 2)
'.Attachments.Add c01
'.Send
Debug.Print .htmlbody
.Display
.Save
.Close o1PromtForSave
Cells(i, 1).Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
End With
Set OutMail = Nothing
Set OutApp = Nothing
End If
Next i
End Sub
Bookmarks