Public Sub SendEmailFromExcelWithBody()
Dim OutApp As Object, OutMail As Object
Dim ws As Worksheet
Dim i As Long, lRow As Long
On Error GoTo Err_Handler
Set OutApp = CreateObject("Outlook.Application")
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 1 To lRow
Set OutMail = OutApp.CreateItem(0)
With OutMail
.Importance = 2
.ReadReceiptRequested = True
.To = ws.Range("A" & i).Value
.Cc = ""
.Bcc = ""
.Subject = "SSCL Devices with Out-dated Security Patches - " & Cells(i, "E")
.HtmlBody = "Good Morning/Afternoon," & _
"Name Assigned to Device: " & ws.Cells(1, 2).Value & _
"<br><br>" & "Device Name: " & ws.Cells(1, 4).Value & _
"<br><br>" & "The device above is assigned to you and has been identified as having out of date security patches." & _
"<br><br>" & "Your device needs to be updated immediately. If you believe this to be incorrect, please contact " & _
"<br><b>" & "Please reply to this email to confirm: " & _
"<br><br>" & "Your device name. Please follow the instructions in the document above"
.Attachments.Add ActiveWorkbook.Path & "\ToEmail.xlsx"
.Display
End With
Next i
End With
Exit_Handler:
Set ws = Nothing
Set OutApp = Nothing
Set OutMail = Nothing
Exit Sub
Err_Handler:
MsgBox "Error Number : " & Err.Number & vbCrLf & "Error Number : " & Err.Description
Resume Exit_Handler
End Sub