<%@LANGUAGE="VBSCRIPT"%> <% '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Spd E-Letter v4 ' © 2001, 2002 PensaWorks, inc. ' For help with this program, please visit http://www.pensaworks.com '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Dim Access : Access = "User" Dim Nav3 : Nav3 = "2" %> <% '======================================== response.buffer = true server.scripttimeout = 1000 if (request("action") <> "") then action = lcase(request("action")) else action = "start" if (request("ListID") <> "" AND IsNumeric(request("ListID"))) Then ListID = CInt(request("ListID")) else ListID = 0 if not allowedList(listID, allowedLists) then response.redirect "message.asp?msg=49" if (request("output") <> "") then output = CInt(request("output")) else output = 1 if (request("fileType") <> "") then fileType = request("fileType") else fileType = "1" if (trim(request("fileName")) <> "") then fileName = trim(request("fileName")) else fileName = "" if (request("delimiter") <> "") then delimiter = request("delimiter") else delimiter = "t" if (request("otherDelimiter") <> "") then otherDelimiter = request("otherDelimiter") else otherDelimiter = "" if (request("FMonth") <> "") then FMonth = request("FMonth") else FMonth = 1 if (request("FDay") <> "") then FDay = request("FDay") else FDay = 1 if (request("FYear") <> "") then FYear = request("FYear") else FYear = 1980 if (request("TMonth") <> "") then TMonth = request("TMonth") else TMonth = 12 if (request("TDay") <> "") then TDay = request("TDay") else TDay = 31 if (request("TYear") <> "") then TYear = request("TYear") else TYear = 2020 FDate = FMonth & "/" & FDay & "/" & FYear : FDate = CDate(FDate) TDate = TMonth & "/" & TDay & "/" & TYear : TDate = CDate(TDate) if (request("minReads") <> "" AND IsNumeric(request("minReads"))) then minReads = CInt(request("minReads")) else minReads = 0 if (request("maxReads") <> "" AND IsNumeric(request("maxReads"))) then maxReads = CInt(request("maxReads")) else maxReads = 9999 if (request("minClicks") <> "" AND IsNumeric(request("minClicks"))) then minClicks = CInt(request("minClicks")) else minClicks = 0 if (request("maxClicks") <> "" AND IsNumeric(request("maxClicks"))) then maxClicks = CInt(request("maxClicks")) else maxClicks = 9999 if action = "export" then if not IsDate(TDate) then msg = 1 : action = "start" else if not IsDate(FDate) then msg = 2 : action = "start" else if output = 2 and fileName = "" then msg = 3 : action = "start" else if (fileType <> 4 AND (delimiter = "o" and otherDelimiter = "")) then msg = 4 : action = "start" else TDateNum = getNumFromDate(TDate) FDateNum = getNumFromDate(FDate) if delimiter = "t" then delimiter = VbTab elseif delimiter = "c" then delimiter = "," elseif delimiter = "p" then delimiter = "|" end if if (delimiter = "o") then exDelimiter = otherDelimiter else exDelimiter = delimiter if (fileType = 3) then exDelimiter = "," strSQL = "SELECT * FROM ML_Subscribers WHERE ListID = " & ListID & " AND SubscribedDate >= " & FDateNum & " AND SubscribedDate <= " & TDateNum & " AND numReads >= " & minReads & " AND numReads <= " & maxReads & " AND numClicks >= " & minClicks & " AND numClicks <= " & maxClicks & " ORDER BY Email ASC" strSQL2 = "SELECT Count(*) AS cnt1 FROM ML_Subscribers WHERE ListID = " & ListID & " AND SubscribedDate >= " & FDateNum & " AND SubscribedDate <= " & TDateNum & " AND numReads >= " & minReads & " AND numReads <= " & maxReads & " AND numClicks >= " & minClicks & " AND numClicks <= " & maxClicks ' response.write strSQL & "

" set getSubscribers = mlConn.Execute(strSQL) set subCount = mlConn.Execute(strSQL2) set getListname = mlConn.Execute("SELECT Listname FROM ML_Lists WHERE ListID = " & listID) listName = getListname("Listname") : set getListname = nothing totalRecords = subCount("cnt1") : set subCount = nothing if fileType = 4 then fileName = fileName & ".xml" exportIt = exportXML() elseif fileType = 3 then endLine = VbCrLf fileName = fileName & ".csv" exportIt = exportFile1() elseif fileType = 2 then endLine = VbCrLf fileName = fileName & ".txt" exportIt = exportFile1() else endLine = "
" fileName = fileName & ".html" exportIt = exportFile1() end if set getSubscribers = nothing end if end if end if end if end if '======================================== function exportXML() if output = 2 then doIt = exportFile(fileName) doIt = writeLine(output, "" & VbCrLf) if output = 2 then doIt = writeLine(output, "" & VbCrLf) else doIt = writeLine(output, "" & VbCrLf) end if doIt = writeLine(output, " " & VbCrLf) doIt = writeLine(output, " " & ListID & "" & VbCrLf) doIt = writeLine(output, " " & Listname & "" & VbCrLf) doIt = writeLine(output, " " & Now & "" & VbCrLf) doIt = writeLine(output, " " & totalRecords & "" & VbCrLf) doIt = writeLine(output, " " & FDate & "" & VbCrLf) doIt = writeLine(output, " " & TDate & "" & VbCrLf) doIt = writeLine(output, " " & MinReads & "" & VbCrLf) doIt = writeLine(output, " " & MaxReads & "" & VbCrLf) doIt = writeLine(output, " " & MinClicks & "" & VbCrLf) doIt = writeLine(output, " " & MaxClicks & "" & VbCrLf) doIt = writeLine(output, " " & VbCrLf) doIt = writeLine(output, " " & VbCrLf) ''''''''''''''''''''''''' Cycle through while NOT getSubscribers.EOF subFormat = whichFormat(getSubscribers("Format")) subDate = getDateFromNum(getSubscribers("SubscribedDate")) if (getSubscribers("subRemoved") = 1) then subStatus = "Removed" else subStatus = "Subscribed" '''''''''''''' doIt = writeLine(output, " " & VbCrLf) doIt = writeLine(output, " " & getSubscribers("Name") & "" & VbCrLf) doIt = writeLine(output, " " & getSubscribers("Email") & "" & VbCrLf) doIt = writeLine(output, " " &subDate & "" & VbCrLf) doIt = writeLine(output, " " & subFormat & "" & VbCrLf) doIt = writeLine(output, " " & getSubscribers("numReads") & "" & VbCrLf) doIt = writeLine(output, " " & getSubscribers("numClicks") & "" & VbCrLf) doIt = writeLine(output, " " & getSubscribers("numBounces") & "" & VbCrLf) doIt = writeLine(output, " " & getSubscribers("numReplies") & "" & VbCrLf) doIt = writeLine(output, " " & subStatus & "" & VbCrLf) doIt = writeLine(output, " " & VbCrLf) '''''''''''''' subdate = "" : subFormat = "" response.flush() getSubscribers.MoveNext() wend '''''''''''''''''''''''' End cylce doIt = writeLine(output, " " & VbCrLf) doIt = writeLine(output, "" & VbCrLf) end function '======================================== function exportFile1() if output = 2 then doIt = exportFile(fileName) line = "Name" & exDelimiter & "Subscribers Email" & exDelimiter & "Subscribe Date" & exDelimiter & "Subscribers Format" & exDelimiter & "Number of Tracked Reads" & exDelimiter & "Number of Tracked Clicks" & exDelimiter & "Number of Tracked Bounces" & exDelimiter & "Number of Tracked Replies" & exDelimiter & "Status" & endLine doIt = writeLine(output, line) while NOT getSubscribers.EOF subFormat = whichFormat(getSubscribers("Format")) subDate = getDateFromNum(getSubscribers("SubscribedDate")) if (getSubscribers("subRemoved") = 1) then subStatus = "Removed" else subStatus = "Subscribed" line = getSubscribers("Name") & exDelimiter & getSubscribers("Email") & exDelimiter & subDate & exDelimiter & subFormat & exDelimiter & getSubscribers("numReads") & exDelimiter & getSubscribers("numClicks") & exDelimiter & getSubscribers("numBounces") & exDelimiter & getSubscribers("numReplies") & exDelimiter & subStatus & endLine doIt = writeLine(output, line) line = "" subdate = "" : subFormat = "" response.flush() getSubscribers.MoveNext() wend end function '======================================== function exportFile(fileName) response.contenttype = "application/octet-stream" response.addheader "Content-Disposition", "attachment; filename=" &fileName response.addheader "Content-Transfer-Encoding","binary" end function '======================================== function writeLine(output, str) if output = 2 then writeOut = writeLineDL(str) else writeOut = writeLineHTML(str) end if end function '======================================== function writeLineDL(str) response.binarywrite str end function '======================================== function writeLineHTML(str) response.write str end function '======================================== if Action = "start" then %> <%=ListName%> - Spd E-Letter Administration

Subscriber Export

<% if msg = 1 then %>

Invalid "From Date".

<% elseif msg = 2 then %>

Invalid "To Date".

<% elseif msg = 3 then %>

When exporting to a file, you must set a filename.

<% elseif msg = 4 then %>

You must choose a delimiter if not exporting to an XML Document.

<% elseif msg = 5 then %>

Error Message

<% end if %>
List to export:
Date Subscribed:
From:
To:
Reads:
Minimum:
Max:
Clicks:
Minimum:
Max:
File Type: > HTML Page
> Text File
> CSV File
> XML File
Export As: > Show in browser
> Export/Save as file
File Name: (no file extension)
Delimiter: > Tab > Comma [ , ] > Pipe [ | ] > Other

<% end if %>