Outlook Mail with Attachemnt & Specific Formated Mail Body

VinodKrishnappa

New Member
Joined
Aug 6, 2016
Messages
31
I've following VBA code for e-mail with an attachment. I want make few modification in the mail body structure.

I want to paste a specific body to be pasted from a different sheet in the same work book with colored, highlighted texts.

Is it possible?

Sub Send_Email()
Dim OutApp As Object
Dim OutMail As Object
Dim sh As Worksheet
Dim iRow As Integer

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

Set sh = Sheets("Sheet1")
Set OutApp = CreateObject("Outlook.Application")
iRow = 3
While Range("A" & iRow).Value <> ""
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = Range("D" & iRow).Value
.Subject = "Form 16"
.Body = "Dear " & Range("B" & iRow).Value & ". " & Range("C" & iRow).Value & "," & vbNewLine & vbNewLine & "Attached please find your Form 16 for the year 2015-16. Please verify and get back to us, if you have any issues." & vbNewLine & vbNewLine & "With best regards," & vbNewLine & "Payroll Team" & vbNewLine
.Attachments.Add Range("E" & iRow).Value
.Send

End With
iRow = iRow + 1
Set OutMail = Nothing
Wend
Set OutApp = Nothing
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Please try it.

Change this line.
Code:
.Body = [COLOR=#ff0000]"Dear " & Range("B" & iRow).Value & ". " & Range("C" & iRow).Value & "," & vbNewLine & vbNewLine & "Attached please find your Form 16 for the year 2015-16. Please verify and get back to us, if you have any issues." & vbNewLine & vbNewLine & "With best regards," & vbNewLine & "Payroll Team" & vbNewLine[/COLOR]


Code:
.BodyFormat = olFormatHTML
.HTMLBody = "<font color=""#FF0000"">Dear " & Range("B" & iRow).Value & ". " & Range("C" & iRow).Value & "," & vbNewLine & vbNewLine & _
"Attached please find your Form 16 for the year 2015-16. Please verify and get back to us, if you have any issues." & _
vbNewLine & vbNewLine & "With best regards," & vbNewLine & "Payroll Team</font>" & vbNewLine
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top