I am trying to set up a macro to allow a colleague to enter some data into a spreadsheet, press a button and it send multiple emails out to multiple recipients with attachments and information taken from the spreadsheet. The colleague wants some of the wording to be in bold and this where i have hit a snag. I can't get the code to be in html and pick up the data from the spreadsheet.
Where this code fails is here: "Name Assigned to Device: " & ws.cells(1, 2).Value & " _
I can't add the cell data and continue to the next line, it seems to want the line to end there
VBA Code:
Sub SendEmailFromExcelWithBody()
Dim OutApp As Object, OutMail As Object
Dim ws As Worksheet
Dim i As Long, lRow As Long
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 = ws.Range("B" & i).Value
.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: (cell.Row, "D").Value & _
"<br><br>The device above is assigned to you and has been identified as having out of date security patches. 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>1. Your device name. Please follow the instructions in the document above" & _
.Attachments.Add "attchement link"
.Attachments.Add "attachment link"
.Display
End With
Next i
End With
End Sub
Where this code fails is here: "Name Assigned to Device: " & ws.cells(1, 2).Value & " _
I can't add the cell data and continue to the next line, it seems to want the line to end there