Email automation of a Report to many people

  • Thread starter Thread starter dwalsh77
  • Start date Start date
D

dwalsh77

I currently have a button that once pressed, does the following:
(1) Selects a company
(2) Generates a report listing all the company's products
(3) Generates an email that places the company's email address in the TO
box, and attaches the report as a HTML attachment

What I would like to do after I press the button is this:
(1) Select all Companies instead of just 1 (ex. 100 companies)
(2) Generates a report for each company individually (as above) but does so
for all 100 companies
(3) Generates an email for each Company, inserts their Company email, and
INSTEAD of attaching the report as an attachment for each company email, it
would insert the Report contents into the body of the email

Basically, if this is possible, their would be 100 emails generated with
each one inserting the report contents into the email body.

Thanks for any help.
 
It would be a lot easier to do this with the attachment rather than
imbedding the report in the body of the email. For one thing, email is
customizable to some extent, so some people may display 80 columns in an
email, while others only display 65. Some email is plain text only, while
some allows HTML or other formatting codes.

Generally, the way I do this is to:

1. create a recordset based on the companies you want to send the report
to.
2. loop through the recordset and set the value of a hidden control on the
form to the value of the CompanyID in the recordset.
3. in the reports query, reference this hidden control in the WHERE clause
of the query, so that when the query is run, it will filter on this value
4. Use the SendObject method to create your email and attach the report,
you can even set it to display the email in outlook for editing if you want
5. loop to the next record in the recordset.

Keep in mind that the Outlook security patches will cause a warning message
to display when you use the SendObject method to make sure you really want
to sent this mail and that some virus is not sending the mail on its own.

HTH
Dale
 
Back
Top