<%@Language = VBScript %> <% Option Explicit %> <% '#File: MailListAdmin_basic.asp - Version 3.01 '# '# This program was written to support basic mailing-list functionality '#without being dependent on an actual email alias for the mailing list. This '#increases the portability while also significantly reducing the possibilitiy '#of spammers spamming members. '# '# This particular file will do one of the following depending on the '#parameters passed to it: '# a is the value for "a" in the query string, which can be any of the following: '# 0 - Print the Configurations for the current list '# 1 - Print the email form to email a message to members of the current list '# 2 - Mail the message to current list '# 8 - Print the members of the current list '# 9 - View all the currently configured Mailing Lists '# '#REQUIREMENTS: '# 1) You must have the file "base64_encode_decode.asp" installed on your server. '# It is included as part of the archive. '# 2) You must have an SMTP server running on the machine this script '# is installed on. '# 3) Must be running on a Microsoft Windows Server running IIS 4.0 or later. '# '#INSTALLATION: '# 1) Set the path to the "include" statements below. If you keep all your files '# in the same directory, you most likely will not have to edit the "include" statements. '# 2) Set the values located in the "MailListConfigs_basic.asp" '# file. ALL VALUES SHOULD BE ENCLOSED IN QUOTES. '# 3) Complete the "installation" section of the file "MailList_basic.asp". '# '#RUNNING: '# 1) The URL to address the Admin interface is: '# http://www.yourdomain.com/scripts/MailListAdmin_basic.asp?a=9 '# '#ADDITIONAL FEATURES AVAILABLE IN THE ADVANCED VERSION: '# 1) Print the Add form to add an email to the current list '# 2) Adding an email to the current list directly, bypassing any '# confirmation emails '# 3) Removing an email from the current list directly, bypassing any '# confirmation emails '# 4) Removing several emails from the current list directly, bypassing '# any confirmation emails '# 5) Displaying the Remove the form to remove an email from the current list '# 6) Web interface to update current list settings '# 7) Web interface to Create a new list '# 8) Web interface to Delete a list '# 9) Web interface to Update URLs '# 10) Support for MULTIPLE lists '# 11) Exporting mail list data to Excel, Word, and a text editor '# 12) Sorting member data by email address or date joined '# '#More details can be found at http://www.davelozinski.com/scripts/ '# '#WHERE/HOW TO PURCHASE THE ADVANCED VERSION '# http://www.davelozinski.com/scripts '# '#LICENSE: '# You are free to further develop/modify the source code to fit your '#needs, but you MAY NOT resell and/or redistribute the source code in any '#way, manner, fashion, or form without my hand-written consent! '# '# This license grants the purchaser of this archive the permission to '#have an unlimited number of users use this script at any time. '#Likewise, the purchaser may have any number of copies of this script as long '#as the media that this programs is stored on or run from is owned by the purchaser. '#If not, more licenses MUST be purchased. '#Examples: '# 1) If you have your own webserver hosting your various customers, you only need once license '#to run the code on your webserver to provide the email functionality to your clients hosted on your server. '# 2) If you are designing websites for 3 individual clients, each of which wants the email functionality, '#and each of which will be hosting their websites and emailer on their own server, '#then you need to purchase 3 licenses. '# '#If you modify the source code in anyway for your own purposes, the '#original header-comments must remain intact. '# '#REVISION HISTORY: '# 3.01 04/08/05 Fixed a bug. "r_send_html_format" undefined. '# 3.00 07/31/04 Updated with advanced script. '# 2.10 07/04/04 Updated with advanced script. '# 2.00 04/12/03 Functionality improved. New features added. '# 1.01 06/18/02 Corrected a mailing bug which stopped the program from emailing '# every member on the list. '# 1.00 03/01/02 Original Version '# '#CONTACT INFORMATION: '# http://www.davelozinski.com/cgi-bin/email_lozinski.pl '# %> <% '################################ '#NOTHING BELOW THIS LINE SHOULD NEED TO BE CONFIGURED '################################ Dim a, e, subject, from , message, datafile a = Request("a") e = Request("e") subject = Request("subject") from = Request("from") message = Request("message") Dim Abbreviation, AnError, ErrorMessage, Title, Admin_Email, Mail_List_Data_File Dim Email_Admin_With_List_Update, Mail_Subscribe_Thank_You_Letter, Send_HTML_Format Dim datestring, output, msg_body, reqMsg, email_address, emails, key Dim fso, file, line, line_arr, found AnError = False %> Mailing List <% If (IsNumeric(a)) Then a = Cint(a) If (a<>0 AND a<>1 AND a<>2 AND a<>8 AND a<>9) Then a = 9 End If Else AnError = True ErrorMessage = ("<H3>An error occurred. You are not accessing this script with the correct URL Query String.<BR><BR>See the documentation for more details.</H3>" & vbcrlf) End If Title = C_TITLE Mail_List_Data_File = C_MAIL_LIST_DATA_FILE If (NOT AnError AND (a <> 9)) Then Admin_Email = C_ADMIN_EMAIL Email_Admin_With_List_Update = CBool(C_EMAIL_ADMIN_WITH_LIST_UPDATE) Mail_Subscribe_Thank_You_Letter = CBool(C_MAIL_SUBSCRIBE_THANK_YOU_LETTER) Send_HTML_Format = CBool(C_SEND_HTML_FORMAT) Response.Write ("for: """ & Title & """" & vbcrlf) End If %> <% If (AnError) Then Response.Write("

" & ErrorMessage & "

") Else '###No error %>

Mail List Administrative Interface


<% '#Print the left hand column of buttons. %>




<% If (a = 0) Then '#Print the configurations for the current list. %>

Current Configurations for: <%=Title%>

Mail List Abbreviation:N/A
URL for Members to add themselves to this list:<%=Script_URL%>
URL for Members to remove themselves to this list:Available in the advanced version
Mail List Title:
The full title for this list.
Email a "thank you" message to each new subscriber?:
Selecting "yes" will have the program email the new subscriber a "thank you" message for joining "<%=Title%>".
Administrator's Email:
Email Admin with each list update?:
Selecting "yes" will have the program email the administrator everytime someone confirms their addition or removal from this list.
Send HTML formatted messages by default?:
Datafile for this mail list:
Full operating system path, including the file name.
NO BACKSLASHES "\"!
Examples:
F:/Inetpub/wwwroot/scripts/maillist/listdata.txt
/var/home/public_html/somedir/datafile.txt
 
<% ElseIf (a = 1) Then '#Print the Email form to mail a message to the members. Set fso = Server.CreateObject("Scripting.FileSystemObject") If (fso.FileExists(C_MAIL_LIST_DATA_FILE)) Then Set file = fso.GetFile(C_MAIL_LIST_DATA_FILE) If (file.Size <> 0) Then %>

Email members of: <%=Title%>

From:

Subject:

Message:


Send as: <% Response.Write("Text  ") Response.Write("HTML  ") %> [Preview]


<% Else '###No members Response.Write ("

There are no members currently subscribed to the mail list """ & Title & """.

" & vbcrlf) End If Set file = Nothing Else Response.Write ("

There are no members currently subscribed to the mail list """ & Title & """.

" & vbcrlf) End If Set fso = Nothing ElseIf (a = 2) Then '#Mail the message to the members on the list. If (StrComp(subject,"") = 0) Then Response.Write ("

You need to provide a subject for your email.

" & vbcrlf) ElseIf (StrComp(from,"") = 0) Then Response.Write ("

You need to specify a ""from"" address for your email.

" & vbcrlf) Else Set fso = Server.CreateObject("Scripting.FileSystemObject") If (fso.FileExists(Mail_List_Data_File)) Then Set file = fso.OpenTextFile(Mail_List_Data_File, 1) Dim successes, failures, errnum, errdesc Set successes = CreateObject("Scripting.Dictionary") Set failures = CreateObject("Scripting.Dictionary") While Not file.AtEndOfStream line = file.ReadLine line_arr = Split(line, "|") email_address = Trim(line_arr(0)) Set reqMsg = Server.CreateObject("CDONTS.NewMail") If (CBool(Send_HTML_Format)) Then reqMsg.BodyFormat = 0 reqMsg.Mailformat = 0 msg_body = "" & Title & "" & vbcrlf Else reqMsg.BodyFormat = 1 reqMsg.Mailformat = 1 End If msg_body = message & vbcrlf If (CBool(Send_HTML_Format)) Then msg_body = msg_body & "

" End If msg_body = msg_body & vbcrlf & vbcrlf & "You are receiving this email because you subscribed to: " & Title & vbcrlf & vbcrlf If (CBool(Send_HTML_Format)) Then msg_body = msg_body & "

" End If msg_body = msg_body & vbcrlf & vbcrlf If (CBool(Send_HTML_Format)) Then msg_body = msg_body & "

" End If Err.Clear On Error Resume Next reqMsg.Send Admin_Email, email_address, subject, msg_body errnum = Err.number errdesc = Err.Description On Error Goto 0 Set reqMsg = Nothing If (errnum = 0) Then successes.Add email_address, 1 Else failures.Add email_address, 1 End If Wend If (failures.Count > 0 AND successes.Count > 0) Then Response.Write ("Click to view members who could not be emailed emailed
" & vbcrlf) Response.Write ("Click to view members successfully emailed
" & vbcrlf) Response.Write ("


" & vbcrlf) End If If (failures.Count > 0) Then Response.Write (" " & vbcrlf) Response.Write ("

These " & failures.Count & " member(s) were not emailed:

" & vbcrlf) For Each key In failures Response.Write (key & "
" & vbcrlf) Next End If Response.Write (" " & vbcrlf) If (successes.Count > 0) Then Response.Write ("

Successfully sent an email to these " & successes.Count & " member(s):

" & vbcrlf) For Each key In successes Response.Write (key & "
" & vbcrlf) Next Else Response.Write ("

No members were successfully emailed.

" & vbcrlf) End If failures.RemoveAll successes.RemoveAll Set failures = Nothing Set successes = Nothing Else Response.Write ("

Error! There are no members currently subscribed to the mail list """ & Title & """!

" & vbcrlf) End If End If ElseIf (a = 8) Then '#Print the current list of members. Dim ScriptObject Set fso = Server.CreateObject("Scripting.FileSystemObject") If (fso.FileExists(Mail_List_Data_File)) Then Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject") Set file = ScriptObject.GetFile(Mail_List_Data_File) If (file.Size > 0) Then %> <% Set file = fso.OpenTextFile(Mail_List_Data_File, 1) Do While Not file.AtEndOfStream line = file.ReadLine If (line <> "") Then line_arr = Split(line, "|") Response.Write ("" & vbcrlf) Response.Write ("" & vbcrlf) Response.Write ("" & vbcrlf) Response.Write ("" & vbcrlf) Response.Write ("" & vbcrlf) End If Loop file.Close Response.Write ("" & vbcrlf) Response.Write ("

<%=Title%> Members:

[export]

Display:
Remove?Email AddressDate Joined
" & line_arr(0) & "" & line_arr(1) & "
  
" & vbcrlf & "" & vbcrlf) Else Response.Write ("

The mail list """ & Title & """ currently has no members.

" & vbcrlf) End If Else Response.Write ("

The mail list """ & Title & """ currently has no members.

" & vbcrlf) End If Set file = Nothing Set fso = Nothing ElseIf (a = 9) Then '#View all current lists %> <% Set fso = Server.CreateObject("Scripting.FileSystemObject") Response.Write ("" & vbcrlf) Response.Write ("" & vbcrlf) Response.Write ("" & vbcrlf) Response.Write ("" & vbcrlf) If (fso.FileExists(C_MAIL_LIST_DATA_FILE)) Then Set file = fso.GetFile(C_MAIL_LIST_DATA_FILE) If (file.Size <> 0) Then Response.Write ("" & vbcrlf) Else Response.Write ("" & vbcrlf) End If Set file = Nothing Else Response.Write ("" & vbcrlf) End If Response.Write ("" & vbcrlf) Set fso = Nothing Response.Write ("

All Mail Lists. Click on a list for specifics.

List AbbreviationList Title 
Basic Test List" & C_TITLE & "[Update][Members]No MembersNo Members
" & vbcrlf) End If %>
<% End If '###Not AnError %>