%
' Newsletter system by MicroSwift.com - Dustin Bolton - http://www.microswift.com
' THIS MUST BE ABOVE ALL!
response.buffer = false
Server.ScriptTimeout = 1500 ' 15 minutes?
%>
Newsletter Sender
<%
if request("action")="send" then
if len(request("subject"))>0 then mySubject=request("subject") else myError=myError & "You must provide a subject. "
if len(request("content"))>0 then myContent=request("content") else myError=myError & "You must enter a body. "
if len(request("priority"))>0 then myPriority=request("priority") else myError=myError & "You must select a priority. "
if len(request("newsletter"))>0 then myNewsletter=request("newsletter") else myError=myError & "You must select a newsletter. "
if len(request("startat"))>0 then myStartat=request("startat") else myStartat=1
if len(myError)>0 then
myError=myError & "
"
end if
end if
if request("action")="" OR len(myerror)>0 then
%>
<%=myError%>
<%
end if
if request("action")="send" AND len(myerror)<1 then
Set db=Server.CreateObject("ADODB.Connection")
db.open "DRIVER={MySQL ODBC 3.51 Driver};Server=localhost;Database=redlightningrecords;UID=redlightning;PWD=mmPScwbr;OPTION=3;"
set rs=server.createObject("ADODB.Recordset")
rs.open "select * from newsletter WHERE newsletter='" & request("newsletter") & "' AND status='1'", db
myLoop=0
mySkip=0
Set objMail = Server.CreateObject("CDONTS.NewMail")
response.write "If this script fails for any reason you may return to the previous page and use the 'start at' feature to resume sending at the specified number.
"
do while NOT rs.eof
myLoop=myLoop+1
if myLoop>=15000 then
response.write "
HALTED
This mail system is set to stop looping after 15,000 emails since it assumes that that many emails do NOT exist in this system. If this is incorrect, please up this number in the script. This is a protective measure to prevent endless loops."
response.end
end if
if myLoop>=int(myStartat) then
myBodyb=myContent
myBodyb=replace(myBodyb,"{email}",rs("Email"))
myBodyb=replace(myBodyb,"{verification}",rs("verification"))
myBodyb=replace(myBodyb,"{verificationurl}","http://project3.microswift.com/newsletter/?" & rs("verification"))
myBodyb=replace(myBodyb,"{unsubscribeurl}","http://project3.microswift.com/newsletter/?u=" & rs("email"))
myBodyb=replace(myBodyb,"{signup}",rs("signup"))
response.write myLoop & ". Sending " & rs("email") & ". "
objMail.Send "Redlightningrecords.com ", rs("email"), mySubject, myBodyb, myPriority
response.write "Sent.
"
myBodyb=""
else
response.write myLoop & ". Skipping.
"
mySkip=mySkip+1
end if
rs.movenext
loop
response.write "
Sent " & myLoop-mySkip & " emails."
set ObjMail=nothing
set myLoop=nothing
db.close
set db=nothing
end if
%>