For each report that you want emailed, you will need to
create an XML (see Listing 3) file with the following report attributes set:
1. server - The name or IP address of the SQL Server
2. database - The name of the database
3. from - Email address used to send from
4. to - A comma separated list of the email addresses you
want the report sent to.
5. mailserver - The name of the email server
6. title - This is the title of the report and the subject
of the email.
7. select - The SQL select statement used for the report
8. sum - The SQL select statement used as a summary for the
9. file - The name of the HTML file that is created and then
To run the report, create a batch file (see Listing 4) that
passes the report file name to the application. Then use Windows Task Scheduler
to run this batch file at the frequency you desire. If you want to run multiple
reports at the same frequency, for example, once a week on Monday at 9:00 AM,
this can be done from one batch file.
If an error occurs, the application creates a file named EmailReports.log
in the same directory and records the error. Any future errors will be added to