<% '****************************** '****x_admin_email.asp*********** '******Cully Radvillas************ '**********CS460************* '****last updated 5/10/06******** 'This program sends out a administrater writen email to all faculty 'to send the email, the sendmail function from X_email.asp(included) 'the mesage and subject are read from a file '******************************* '***declare your variables Dim connection1, recordset1 Dim strSQL1, sConnString1 dim strSQL2 dim admin, failmail dim fs, ms, ss dim f, m, s dim msgend '***set message footer msgend = vbcrlf& vbcrlf& "Thank you for using the NVS Voting system " msgend = msgend + vbcrlf& "please go to http://vote to view committee details" msgend = msgend + vbcrlf& "*****Please do not reply to this email address*****" msgend = msgend + vbcrlf& "*****Contact NVS administrator with concerns******" '***********declare SQL statement that will query the database strSQL1 = "SELECT EMAIL, LOGIN_ID FROM FACULTY;" '*************** an ADO connection and recordset object Set connection1 = Server.CreateObject("ADODB.connection") Set recordset1 = Server.CreateObject("ADODB.Recordset") '*****define the connection string, specify database *** '**********driver and the location of database ******** sConnString1="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("../database/dbNVS.mdb") '*********Open the connection to the database Connection1.Open sConnString1 '***Open the recordset object, executing the SQL Recordset1.Open strSQL1, Connection1 '***create bademail.txt set fs=Server.CreateObject("Scripting.FileSystemObject") set f=fs.OpenTextFile("badmail.txt",2,true) '***open mesage and subject files for reading set ms=Server.CreateObject("Scripting.FileSystemObject") set m=ms.OpenTextFile("Admin_message.txt",1,true) set ss=Server.CreateObject("Scripting.FileSystemObject") set s=ss.OpenTextFile("Admin_subject.txt",1,true) subject=s.readall '***setting x_email subject from file s.close message=m.readall + msgend '***setting x_email message from file m.close fromwho="votingsystem@snc.edu" '***set sender email address recordset1.MoveFirst do while not recordset1.EOF if ((subject <> "***no subject***") and (message <> "***no input***"))then 'if msg and sbj are not blank towho=recordset1("EMAIL").value '***set email address to be sent to If toWho <> "" THEN Response.Write toWho sendMail fromWho, toWho, Subject, message '***fcn to send email using x_email.asp else '***failed mail (no email address) failmail=failmail+1 f.WriteLine(recordset2("LOGIN_ID").Value) '*******write bad emails to file END IF end if recordset1.MoveNext loop if failmail>0 then '***if there are empty emails, send email to admin set f=fs.OpenTextFile("badmail.txt",1,true)'***open to read file message = f.readall'***read file sendMail "badmailNVS@snc.edu", admin, "Bad Emails NVS", message'***send using x_email.asp end if '********general cleanup********* recordset1.Close Set recordset1 = Nothing connection1.Close Set connection1 = Nothing f.close set f = nothing set fs = nothing '***Cleanup for x_email Set ObjCDO = Nothing Set iConf = Nothing Set Flds = Nothing Response.Redirect ("admin_main.asp") %>