In Access I have a table that contains email addresses. On a form I have a button that prints reports. How would I also have these reports sent via email to the recipients in this table?
Use a recordset to go through each of the records in turn and use the docmd.sendobject command to send the email.
The code would be something like this:
Private sub sendmail()
dim db as database, rs as recordset
set db = currentDB
set rs = db.openrecordset("myTableName", dbopendynaset)
rs.movefirst
do until rs.noMatch
DoCmd.SendObject acSendReport, "reportname", , rs!emailaddress, , , "Report Attached", "This is the text of the message", 0
rs.movenext
loop
end sub
where emailaddress is the name of the field in your table and Report Attached is the subject line of the email
The code may not be exactly right as I have worked from memeory, but it won't be far off.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.