My query for automating emails is coming up with the following error: User defined type not defined. I have the right object libraries selected in the References so am not sure how to fix this. The code is below. I can send a copy of the spreadsheet as well if that would help.
VBA code:
Sub sendemail()
Dim OutApp As New Outlook.Application
Dim OutMail As MailItem
LR = Cells(Rows.Count, "B").End(xlUp).Row
bodySignature = "Kind regards," & vbLf & "Quality Assurance Team"
For r = 2 To LR
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = Range("C" & r).Value
.Subject = Range("D" & r).Value
bodyHeader = "Dear " & Range("B" & r).Value & ","
bodyMain = Range("E" & r).Value
.Body = bodyHeader & vbLf & bodyMain & vbLf & bodySignature
.Attachments.Add Range("F" & r).Value
.Display
End With
Next r
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
VBA code:
Sub sendemail()
Dim OutApp As New Outlook.Application
Dim OutMail As MailItem
LR = Cells(Rows.Count, "B").End(xlUp).Row
bodySignature = "Kind regards," & vbLf & "Quality Assurance Team"
For r = 2 To LR
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = Range("C" & r).Value
.Subject = Range("D" & r).Value
bodyHeader = "Dear " & Range("B" & r).Value & ","
bodyMain = Range("E" & r).Value
.Body = bodyHeader & vbLf & bodyMain & vbLf & bodySignature
.Attachments.Add Range("F" & r).Value
.Display
End With
Next r
Set OutMail = Nothing
Set OutApp = Nothing
End Sub