Purpose:
The purpose of this script is to build files from queries and send the corresponding links to a list of users.

Download
Files:
blat.exe (a public domain program in charge of mailing)
<query>.bat (the main script)
<query>.cfg (the main configuration file)
<query>.vbs (the vbscript in charge of running the queries and generating the corresponding files)
queries_for_user1.cfg (a file that contains the query to be run)

Setup:
1. Extract the zip file in the destination directory.

2. If you decide to rename <query>.bat, you will also have to rename the <query>.cfg and <query>.vbs files.

3. Edit the <query>.bat file and change the SMTP_SERVER and SENDER variables as appropriate
eg:
SET SMTP_SERVER=smtp.server.com
SET SENDER=noreply@server.com

4. Edit the <query>.cfg file (a tab delimited file) and add (replace) as many lines as required:
SMTPDest: The email address that will receive the mail
QueryFullFilePath: The file that contains the queries (and other information)
EmailSubject: The corresponding email subject

5. Edit (create) the query files as follows (there should be as many lines as queries for a given user):
ConnectionString: DSNLess database connection string
Query: The query
OutputFile: An absolute file path that contains the result of the query (the user that will receive the email is supposed to have the appropriated credentials/accesses)

Usage:
Once configured you just have to double-click on the <query>.bat file (the best thing is probably to setup a scheduled task).