Hi Please help me!!!! I have little experience in programming. I have a table called employees that has names and email addresses. What I would like to do is send automated email to all the people in the table using the email addresses. I have the code that will send email but the amount of people who are getting it is too many and may change often. The code below creates a report then send emails using CDO. I just don't understand how to pull the emails from the tables into the code.
X = is used to block out the real information.
Code:
Private Sub Email_Report_Click()
On Error GoTo error
DoCmd.OutputTo acOutputReport, "NAMEOFREPORT", acFormatPDF, "C:\reports\Report1.pdf", 0
MsgBox "Your report has been generated and sent via email", vbOKOnly, "Make Labels"
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Export License Track"
objMessage.From = "XXX@XXX.com"
objMessage.To = "XXX@XXX.com"
objMessage.TextBody = "Report has been created and emailed. Please do not reply back to this email"
objMessage.AddAttachment "C:\reports\Report1.pdf"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/con...tion/sendusing") = 2
'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/con...ion/smtpserver") = "XXX.XXX.com"
'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/con...smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
error: Exit Sub
End Sub