%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim oConn
Dim oRS
Dim sSQL
Dim sStatusMessage
Dim sConnectionString
dim emailbox
dim emails
dim i
sStatusMessage = ""
If request("btnAddCategory") = "add category" Then
query = "INSERT INTO ICategory (Category) VALUES ('" & sqlsafe(request("txtNewCategory"), 255) & "')"
DBConn.execute(query)
sStatusMessage = "New Category added."
end if
if request("button2") = "Add New Emails" Then
' Get all the emails from the textbox.
' Send all the emails a confirmation email as in the normal signup
' Also add the user to the particular category
' Also need to check if email already exists in the database before adding it
emailbox = request("emailbox")
emails = split(emailbox, vbcrlf, -1)
for i = 0 to UBound(emails)
FirstName = ""
LastName = ""
EmailAddress = trim(emails(i))
HomePhone = ""
WorkPhone = ""
Mobile = ""
theState = ""
Country = ""
Birthdate = ""
Category = request("lstCategory")
Gender = ""
ICategoryID = request("lstCategory")
EmailJoinDate = now()
if request("optHTMLEmail") = "yes" then
HTMLEmail = true
else
HTMLEmail = false
end if
' check if email exists in the mailing list
query = "SELECT * FROM IMailingList WHERE Email = '" & EmailAddress & "'"
'Response.write query
'Response.end
set rsEmail = DBConn.execute(query)
if rsEmail.EOF then
' If it doesn't then add them to the mailing list
' need to generate a random validation code for this
Password = generatePassword(1)
query = "INSERT INTO IMailingList(ICategoryID, JoiningDate, FirstName, LastName, Email, State, Country, Birthdate, Gender, IsActive, ActivationCode, HomePhone, WorkPhone, MobilePhone, HTMLEmail) VALUES (" & ICategoryID & ",#" & now() & "#,'" & FirstName & "','" & LastName & "','" & EmailAddress & "','" & theState & "','" & Country & "','" & Birthdate & "','" & Gender & "', false,'" & Password & "','" & HomePhone & "','" & WorkPhone & "','" & Mobile & "'," & HTMLEmail & ")"
'Response.write query
'Response.end
DBConn.execute(query)
sStatusMessage = sStatusMessage & emails(i) & " - added successfully
"
else
Password = rsEmail("ActivationCode")
sStatusMessage = sStatusMessage & emails(i) & " - e-mail address already subscribed
"
end if
rsEmail.Close
set rsEmail = nothing
' Decide whether the user wants HTML email or plain text email as to whether it displays the database
if HTMLEmail = true then
content = CONFIRMATION_EMAIL_CONTENT & "
"
content = content & "Activation Code : " & Password & "
"
content = content & "In order to activate your entry in the mailing list click here"
else
content = CONFIRMATION_EMAIL_CONTENT & vbcrlf & vbcrlf
content = content & "Activation Code : " & Password & vbcrlf
content = content & "In order to activate your entry in the mailing list use this link http://" & Request.ServerVariables("SERVER_NAME") & LocationPhyPath & "activate-user.asp?EmailAddress=" & emailrecipient & "&ActivationCode=" & emailpassword
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 HTMLEmail then
JMail.ContentType = "text/html"
else
JMail.ContentType = "text/plain"
end if
JMail.AddRecipient request("txtEmailAddress")
JMail.Sender = SENDER_EMAIL
JMail.SenderName = SENDER_EMAIL_NAME
JMail.Subject = "Mailing List Confirmation"
JMail.Body = content
JMail.Logging = True
JMail.Execute
set JMail = Nothing
else
' otherwise do this
' Attempt to send email to recipient
SendEmail MAIL_COMPONENT, MAIL_SERVER, EmailAddress, "", "", SENDER_EMAIL, SENDER_EMAIL_NAME, SENDER_EMAIL, SENDER_EMAIL_NAME, "Mailing List Confirmation", content, "", HTMLEmail
end if
next
End If
%>
![]() |