home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
bombers.k12.ar.us
/
bombers.k12.ar.us.tar
/
bombers.k12.ar.us
/
survey_unconfigured
/
ImportEmailAddressesAction.asp
< prev
next >
Wrap
Text File
|
2006-10-25
|
5KB
|
132 lines
<!--#Include File="Include/Top_inc.asp"-->
<%
'***********************************************************************
' Application: SelectSurveyASP Advanced v8.1.11
' Author: Aaron Baril for ClassApps.com
' Page Description: This page is called from ImportEmailAddresses.asp and does the
' actual importing of email addresses into the database.
'
' COPYRIGHT NOTICE
'
' See attached Software License Agreement
'
' (c) Copyright 2002 - 2006 by ClassApps.com. All rights reserved.
'***********************************************************************
%>
<!--#Include File="Include/SurveyUtility_inc.asp"-->
<!--#Include File="Include/Utility_inc.asp"-->
<!--#Include File="Include/Constants_inc.asp"-->
<!--#Include File="Include/Config_inc.asp"-->
<!--#Include File="Include/ID_inc.asp"-->
<!--#Include File="Include/adovbs_inc.asp"-->
<!--#Include File="Include/CurrentUser_inc.asp"-->
<!--#Include File="Include/SurveySecurity_inc.asp"-->
<%
'If the user does not have "Create" or "Admin" permission, redirect them to the access denied page.
If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
End If
Dim arrEmailAddresses
Dim arrFields
Dim i
Dim strEmailAddress
Dim strFirstName
Dim strLastName
Dim strCustomData1
Dim strCustomData2
Dim strCustomData3
Dim conImport
Dim lngEmailAddressID
Dim strSQL
Dim lngEmailAddressCount
Dim lngEmailListID
'Initialization
Set conImport = Server.CreateObject("ADODB.Connection")
lngEmailListID = Request.Form("EmailListID")
conImport.Open SURVEY_APP_CONNECTION
strFirstName = ""
strLastName = ""
strCustomData1 = ""
strCustomData2 = ""
strCustomData3 = ""
lngEmailAddressCount = 0
'Split the list of email addresses on the linefeed character. Each record contains an email address, followed
'by, optionally, first name, last name, and custom data.
arrEmailAddresses = Split(Trim(Request.Form("txtEmailAddresses")), vbCrLf)
'Loop through the records entered.
For i = 0 To UBound(arrEmailAddresses)
'Make sure that data was entered on each line before processing
If Len(arrEmailAddresses(i)) > 0 Then
'Split the fields on comma
arrFields = Split(Trim(arrEmailAddresses(i)), ",")
'Get the email address, which is the first field, and is required. Trim to 75 characters, which is the max length.
strEmailAddress = Left(arrFields(0), 75)
'Get the first name, which is the second field, if provided. Trim to 75 characters, which is the max length.
If UBound(arrFields) >= 1 Then
strFirstName = Left(arrFields(1), 75)
End If
'Get the last name, which is the third field, if provided. Trim to 75 characters, which is the max length.
If UBound(arrFields) >= 2 Then
strLastName = Left(arrFields(2), 75)
End If
'Get the first custom data field, which is the fourth field, if provided. Trim to 75 characters, which is the max length.
If UBound(arrFields) >= 3 Then
strCustomData1 = Left(arrFields(3), 75)
End If
'Get the second custom data field, which is the fifth field, if provided. Trim to 75 characters, which is the max length.
If UBound(arrFields) >= 4 Then
strCustomData2 = Left(arrFields(4), 75)
End If
'Get the third custom data field, which is the sixth field, if provided. Trim to 75 characters, which is the max length.
If UBound(arrFields) >= 5 Then
strCustomData3 = Left(arrFields(5), 75)
End If
'Get the next available email address ID
lngEmailAddressID = ID_GetNextAvailableID("SurveyGenerationEmailAddress")
'Create the INSERT statement and execute
strSQL = "INSERT INTO sur_email_address(email_address_id, email_list_id, email_address, first_name, " & _
"last_name, custom_data_1, custom_data_2, custom_data_3, active_yn, deleted_yn) VALUES(" & _
lngEmailAddressID & ", " & _
lngEmailListID & ", " & _
SQLEncode(strEmailAddress) & ", " & _
SQLEncode(strFirstName) & ", " & _
SQLEncode(strLastName) & ", " & _
SQLEncode(strCustomData1) & ", " & _
SQLEncode(strCustomData2) & ", " & _
SQLEncode(strCustomData3) & ", " & _
SQLEncode(SUR_BOOLEAN_POSITIVE) & ", " & _
SQLEncode(SUR_BOOLEAN_NEGATIVE) & ")"
conImport.Execute ConvertSQL(strSQL), , adCmdText
'Increment the count of email addresses inserted
lngEmailAddressCount = lngEmailAddressCount + 1
End If
Next
'Update the count of email addresses for this list
strSQL = "UPDATE sur_email_list " & _
"SET email_address_count = email_address_count + " & lngEmailAddressCount & _
" WHERE email_list_id = " & lngEmailListID
conImport.Execute ConvertSQL(strSQL), , adCmdText
'Clean up
conImport.Close
Set conImport = Nothing
'Redirect to the main page for the email list for which email addresses were just imported
Response.Redirect "EmailListList.asp"
%>