Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code that uses Outlook to email reports from MS Access

Status
Not open for further replies.

avatarp

Technical User
Jul 3, 2002
22
CA
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.

HTH

Rick

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top