Can someone please tell me what I'm doing wrong? I'm getting "Object Variable or With Block Variable not set"
Thanks!!
Dim db As Database
Dim rs As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set db = CurrentDb
Set rs = db.OpenRecordset("qry_EmailAddress")
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
rs.MoveFirst
Do Until rs.EOF
With objEmail
.To = rs!Email
.Subject = rs!MemberName
.HTMLBody = "Test<br><br>"
.Attachments.Add (rs!FilePath)
.Send
End With
Set objEmail = Nothing
rs.MoveNext
Loop
Thanks!!
Dim db As Database
Dim rs As DAO.Recordset
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set db = CurrentDb
Set rs = db.OpenRecordset("qry_EmailAddress")
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
rs.MoveFirst
Do Until rs.EOF
With objEmail
.To = rs!Email
.Subject = rs!MemberName
.HTMLBody = "Test<br><br>"
.Attachments.Add (rs!FilePath)
.Send
End With
Set objEmail = Nothing
rs.MoveNext
Loop