%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
response.buffer = false
Session.Timeout=330
%>
<%
' Delete a mailout
if request("action") = "delete" then
IMailOutID = request("IMailOutID")
if IMailOutID > 0 then
' Firts delete any of the entries from IMailSent
query = "DELETE FROM IMailSent WHERE IMailOutID = " & IMailOutID
DBConn.execute(query)
' Delete the mailout from IMailOut
query = "DELETE FROM IMailOut WHERE IMailOutID = " & IMailOutID
DBConn.execute(query)
sStatusMessage = "Mailout deleted"
end if
end if
' Resume a mailout
if request("action") = "resume" then
IMailOutID = request("IMailOutID")
if IMailOutID > 0 then
' Get details of the particular mailout
query = "SELECT * FROM IMailOut WHERE IMailOutID = " & IMailOutID
set rsMailOut = CreateObject("ADODB.RecordSet")
rsMailOut.CursorType = 3
set rsMailOut.ActiveConnection = DBConn
rsMailOut.Source = query
rsMailOut.Open
if not rsMailOut.EOF then
IsHTML = rsMailOut("IsHTML")
DateSent = rsMailOut("MailOutDate")
CategoryID = rsMailOut("ICategoryID")
Subject = rsMailOut("Subject")
Message = rsMailOut("Message")
end if
rsMailOut.Close
set rsMailOut = nothing
' Check that there is actually a mail subject, message etc to send before attempting to
if Subject <> "" then
response.write("Sending Mail .")
'Attempt to send the mail to each of the recipients in the list
query = "SELECT * FROM IMailSent WHERE IMailOutID = " & IMailOutID & " AND MailSent = false"
set rsSend = CreateObject("ADODB.RecordSet")
rsSend.CursorType = 3
set rsSend.ActiveConnection = DBConn
rsSend.Source = query
rsSend.Open
do until rsSend.EOF
' Get the user id of the user to send mail to
IUserID = rsSend("IMailingListID")
' Get the email address and name of the recipient to send the mail to
query = "SELECT * FROM IMailingList WHERE IMailingListID = " & IUserID
set rsUser = CreateObject("ADODB.RecordSet")
rsUser.CursorType = 3
set rsUser.ActiveConnection = DBConn
rsUser.Source = query
rsUser.Open
if not rsUser.EOF then
emailrecipient = rsUser("Email")
emailpassword = rsUser("ActivationCode")
'recipientname = rsUser("RecipientName")
IsHTML = rsUser("HTMLEmail")
' Put the unsubscribe info into the mailout message
MessageToSend = ""
sTrailerText = "to unsubscribe, use this link http://" & Request.ServerVariables("SERVER_NAME") & LocationPhyPath & "unsubscribe.asp?EmailAddress=" & emailrecipient & "&ActivationCode=" & emailpassword
sTrailerHTML = "to unsubscribe, click here"
If IsHTML = false Then
MessageToSend = sTrailerText & vbCrLf & MessageTextOnly & vbCrLf & sTrailerText
Else
MessageToSend = sTrailerHTML & " " & Message & " " & sTrailerHTML
End If
' If they are using jmail then use this function
if MAIL_COMPONENT = "Jmail" then
Set JMail = Server.CreateObject("jmail.smtpmail")
JMail.ServerAddress = MAIL_SERVER
if IsHTML then
JMail.ContentType = "text/html"
else
JMail.ContentType = "text/plain"
end if
JMail.AddRecipient rsUser("Email")
JMail.Sender = SENDER_EMAIL
JMail.SenderName = SENDER_EMAIL_NAME
JMail.Subject = Subject
JMail.Body = MessageToSend
JMail.Logging = True
JMail.Execute
set JMail = Nothing
else
' otherwise do this
' Attempt to send email to recipient
SendEmail MAIL_COMPONENT, MAIL_SERVER, emailrecipient, "", "", SENDER_EMAIL, SENDER_EMAIL_NAME, SENDER_EMAIL, SENDER_EMAIL_NAME, Subject, MessageToSend, "", IsHTML
end if
' If successful mark the email as sent
currentdate = now()
query = "UPDATE IMailSent SET MailSent = true, DateSent = #" & currentdate & "# WHERE ID = " & rsSend("ID")
DBConn.execute(query)
response.write(".")
end if
rsUser.close
set rsUser = nothing
rsSend.movenext
loop
rsSend.Close
set rsSend = nothing
end if
end if
end if
%>
<%= WebsiteTitle %>
ADMIN
Resume Mailout
<%=sStatusMessage%>
Mailout Subject
Date Sent
Status
Options
<%
' Select all the mailouts from the database
query = "SELECT * FROM IMailOut ORDER BY MailoutDate desc"
set rsMailOut = DBConn.execute(query)
do until rsMailOut.EOF
response.write("
" & rsMailOut("Subject") & "
" & rsMailOut("MailOutDate") & "
")
' Calculate status of the current mailout
' Get total number of entries in this mailout
query = "select count(*) as TotalMailcount from IMailSent WHERE IMailOutID = " & rsMailOut("IMailOutID")
set rsTotal = DBConn.execute(query)
if not rsTotal.EOF then
TotalMailCount = rsTotal("TotalMailcount")
else
TotalMailCount = 0
end if
rsTotal.Close
set rsTotal = nothing
' Get total number of sent entries in this mailout
query = "select count(*) as TotalMailcount from IMailSent WHERE MailSent = true AND IMailOutID = " & rsMailOut("IMailOutID")
set rsTotal = DBConn.execute(query)
if not rsTotal.EOF then
TotalMailCountSent = rsTotal("TotalMailcount")
else
TotalMailCountSent = 0
end if
rsTotal.Close
set rsTotal = nothing
if TotalMailCount = TotalMailCountSent then
response.write("
Complete
")
else
response.write("
" & TotalMailCountSent & "/" & TotalMailCount & "
")
end if
response.write("
")
' If the mailout is not complete give the option to resume
if TotalMailCountSent < TotalMailCount then
response.write("[Resume] ")
end if
' Give the user the option of deleting the mailout
response.write("[Delete]
")
rsMailOut.movenext
loop
rsMailOut.Close
set rsMailOut = nothing
%>