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
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