%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Newsletters and Mailing List ' Product : CandyPress Store Administration ' Version : 2.5 ' Modified : February 2004 ' Copyright: Copyright (C) 2004 CandyPress.Com ' See "license.txt" for this product for details regarding ' licensing, usage, disclaimers, distribution and general ' copyright requirements. If you don't have a copy of this ' file, you may request one at webmaster@candypress.com '************************************************************************* Option explicit Response.Buffer = true const adminLevel = 1 server.ScriptTimeout = 18000 'Set to 5 hours due to newsletters %> <% 'Declare variables dim mySQL, cn, rs 'Newsletters dim idNews dim newsBookmark dim newsSubj dim newsBody dim newsPreview dim contType 'Work Fields dim custType dim custPaid dim action dim custList dim I, I2 'Additional Newsletter Variables dim custListEmail(20) 'Change to modify email batch size dim strUA dim nPctComplete '************************************************************************* 'Open Database Connection call openDB() 'Store Configuration if loadConfig() = false then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Could not load Store Configuration settings.") end if 'Get general form values custType = trim(Request.Form("custType")) custPaid = trim(Request.Form("custPaid")) action = trim(Request.Form("action")) 'Get newsletter form values idNews = trim(Request.Form("idNews")) newsBookmark= trim(Request.Form("newsBookmark")) newsSubj = trim(Request.Form("newsSubj")) newsBody = trim(Request.Form("newsBody")) newsPreview = trim(Request.Form("newsPreview")) contType = trim(Request.Form("contType")) 'Check custType if custType <> "A" _ and custType <> "I" _ and custType <> "O" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Customer selection.") end if 'Check custPaid if custPaid <> "Y" then custPaid = "N" end if 'Check Action if action <> "D" _ and action <> "F" _ and action <> "E" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Action selected.") end if 'If newsletter, check that email is enabled if action = "E" and mailComp = "0" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Email must be enabled in order to send newsletters.") end if 'Check newsletter info if action = "E" then if len(idNews) > 0 then idNews = cLng(idNews) end if if len(newsSubj) = 0 then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Subject for Newsletter.") end if if len(newsBody) = 0 then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Message for Newsletter.") end if if newsPreview <> "Y" then newsPreview = "N" end if if isNumeric(contType) then contType = CLng(contType) else contType = 0 end if end if 'If the user requested a Preview newsletter, we can skip most of the 'code and just execute the bit of code below. if action = "E" and newsPreview = "Y" then %>
Newsletters and Mailing Lists
|
A preview of the newsletter was sent to : <%=pEmailSales%> Check your Email Inbox to see if this email was delivered, and if the content and format of the email is correct. Press the 'BACK' button on your browser to return to the newsletter to make changes and submit another preview, or to submit the newsletter to all your customers (remember to un-check the 'Preview' box first). |
Newsletters and Mailing Lists
|
Total number of emails to send : <%=ubound(custList,2)+1%> <% 'Loop through recordset array. Emails are assigned to an email 'array (from the recordset array) so they can be sent in batches. for I = 0 to ubound(custList,2) 'Move email address to email array custListEmail(I2) = custList(0,I) 'Increment email array counter I2 = I2 + 1 'Check if we need to send a batch of emails if I2 >= ubound(custListEmail) or I >= ubound(custList,2) then 'Send a batch of emails on error resume next call sendmail (pCompany, pEmailSales, custListEmail, newsSubj, newsBody, contType) if err.number <> 0 then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("An error occurred while sending email." & err.Description) end if on error goto 0 'Update checkpoint. We open and close the database 'connection before and after each update because the 'script may run for a very long time, so we need to 'ensure that other scripts also get an opportunity. call openDb() if I < ubound(custList,2) then mySQL = "UPDATE newsletters " _ & "SET newsBookmark = '" & custList(0,I) & "' " _ & "WHERE idNews = " & idNews else mySQL = "UPDATE newsletters " _ & "SET newsBookmark = NULL " _ & "WHERE idNews = " & idNews end if set rs = openRSexecute(mySQL) call closeRS(rs) call closedb() 'Display checkpoint Response.Write "Sent -> " & I+1 & " emails (Last email : " & custList(0,I) & ") " 'Reset email array counter and values I2 = 0 erase custListEmail 'Is the client still connected? if not Response.IsClientConnected then Response.End end if 'Update Progress Window if strUA = "IE" then nPctComplete = ( (I+1) / (ubound(custList,2)+1)) * 100 Response.Write "" & vbCrLf else Response.Write "" & vbCrLf end if 'Send buffered output to browser Response.Flush end if next 'Close Progress Window Response.Write "" & vbCrLf %> Total number of emails sent : <%=ubound(custList,2)+1%> |
| Full Name | |
| " & custList(0,I) & " | " & custList(1,I) & ", " & custList(2,I) & " |