I'm trying to create an email for every row of data on my sheet.
It seems to be working until I add the .Attachments.Add
line.
I am trying to identify the file path from a cell.
Sub CreateEmails()
Dim objOutlook As Object
Set objOutlook = CreateObject("Outlook.Application")
Dim objEmail As Object
Dim eBody As String
Range("A2").Select
Do Until IsEmpty(ActiveCell)
Set objEmail = objOutlook.CreateItem(olMailItem)
eBody = "<p>Hi " & ActiveCell(0, 1).Value & ", </p>" _
& "<p>Message Body</p>" & _
"<p>Thank you!</p><br>"
With objEmail
.to = ActiveCell(0, 2).Value
.Subject = ActiveCell(0, 3).Value
.HTMLBody = "<html><head></head><body>" & eBody & "</body></html>"
.Attachments.Add ActiveCell(0, 5).Value
.Display
End With
ActiveCell.Offset(1, 0).Select
Loop
End Sub