
April 24th, 2008, 04:19 AM
|
|
Contributing User
|
|
Join Date: Sep 2002
Location: Canberra, Australia
Posts: 317
  
Time spent in forums: 19 h 42 m 18 sec
Reputation Power: 7
|
|
|
ASP Send mail
Hi there I have this script integrated with a file upload script see here
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=8525&lngWId=4
it allows you to upload files to the server. I needed it to send an email, I had it working on my DEV and then on the Prod box it fails at Line 151.. Which is where the script attempts to attach the files to the mail..
Can anyone see anything wrong with the script, that would cause this error?
Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#INCLUDE Virtual="/mail_scripts/upload/clsUpload.asp"-->
<%
Dim Upload 'As Object
Dim Folder 'As String
Dim fso 'As Object
Dim objMail 'As Object
Dim MyServer 'As String
Dim LiveWeb 'As String
Dim strjobReference 'As String
Dim strcpGrade 'As String
Dim strcpLocation 'As String
Dim strMessage 'As String
Dim strFromEmail 'As String
Dim strSubject 'As String
Dim strRedirect 'As String
Dim strTitle 'As String
Dim strName 'As String
Dim strSurname 'As String
Dim strCurrWork 'As String
Dim strAddress 'As String
Dim strWorkPhone 'As String
Dim strHomePhone 'As String
Dim strRef1name 'As String
Dim strRef1contact 'As String
Dim strRef2name 'As String
Dim strRef2contact 'As String
Dim Ext01
Dim Ext02
Dim FileOK
Set Upload = New clsUpload
Set fso = CreateObject("Scripting.FileSystemObject")
'DESIGN TOOLS ===========================================================================
MyServer = Request.ServerVariables("SERVER_NAME")
If LCase(MyServer) = "localhost" Then
LiveWeb = "False"
Else
LiveWeb = "True"
End If
'END DESIGN TOOLS ===========================================================================
' Change the cTo value to be the email you want to send the mail to.
Const cTo = "email@domain.com.au"
'-----------------------------------------------------------------
' Set vars and Build Email
'-----------------------------------------------------------------
strRedirect = Upload.Fields("redirect").value
strFromEmail = Upload.Fields("email").value
strSubject = Upload.Fields("subject").value
strjobReference = Upload.Fields("jobReference").value
strcpGrade = Upload.Fields("cpGrade").value
strcpLocation = Upload.Fields("cpLocation").value
strTitle = Upload.Fields("title").value
strName = Upload.Fields("fname").value
strSurname = Upload.Fields("lname").value
strCurrWork = Upload.Fields("wrkloc").value
strAddress = Upload.Fields("corraddress").value
strWorkPhone = Upload.Fields("wphone").value
strHomePhone = Upload.Fields("hphone").value
strFromEmail = Upload.Fields("email").value
strRef1name = Upload.Fields("ref1name").value
strRef1contact = Upload.Fields("ref1contact").value
strRef2name = Upload.Fields("ref1name").value
strRef2contact = Upload.Fields("ref1contact").value
strMessage = "<HTML><HEAD>"
strMessage = strMessage & "<STYLE> BODY,TABLE, TD, P {FONT-FAMILY: Verdana; FONT-SIZE: 10pt;}</STYLE>"
strMessage = strMessage & "</HEAD><BODY>"
strMessage = strMessage & "<h2>Online application</h2>"
strMessage = strMessage & "<p><b>Position information</b></p>"
strMessage = strMessage & "<table width='600' cellpadding='0' cellspacing='5'>"
strMessage = strMessage & "<tr><td width='200'>Job Reference Number:</td><td width='400'>" & strjobReference & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Campbell Page Grade:</td><td width='400'>" & strcpGrade & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Vacancy Location:</td><td width='400'>" & strcpLocation & "</td></tr>"
strMessage = strMessage & "</table>"
strMessage = strMessage & "<p><b>Applicants details</b></p>"
strMessage = strMessage & "<table width='600' cellpadding='0' cellspacing='5'>"
strMessage = strMessage & "<tr><td width='200'>Name:</td><td width='400'>" & strTitle & " " & strName & " " & strSurname & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Address:</td><td width='400'>" & strAddress & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Current workplace:</td><td width='400'>" & strCurrWork & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Phone (w):</td><td width='400'>" & strWorkPhone & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Phone (h):</td><td width='400'>" & strHomePhone & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Email:</td><td width='400'>" & strFromEmail & "</td></tr>"
strMessage = strMessage & "</table>"
strMessage = strMessage & "<p><b>Referree details (1)</b></p>"
strMessage = strMessage & "<table width='600' cellpadding='0' cellspacing='5'>"
strMessage = strMessage & "<tr><td width='200'>Name:</td><td width='400'>" & strRef1name & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Contact Details:</td><td width='400'>" & strRef1contact & "</td></tr>"
strMessage = strMessage & "</table>"
If strRef2name <> "" Then
strMessage = strMessage & "<p><b>Referree details (2)</b></p>"
strMessage = strMessage & "<table width='600' cellpadding='0' cellspacing='5'>"
strMessage = strMessage & "<tr><td width='200'>Name:</td><td width='400'>" & strRef2name & "</td></tr>"
strMessage = strMessage & "<tr><td width='200'>Contact Details:</td><td width='400'>" & strRef2contact & "</td></tr>"
strMessage = strMessage & "</table>"
End If
strMessage = strMessage & "</HTML></BODY>"
'-----------------------------------------------------------------
' Upload files
'-----------------------------------------------------------------
' For reference...
' 1 KB = 1024 Bytes
' 10 KB = 10240 Bytes
' 100 KB = 102400 Bytes
' 1 MB = 1048576 Bytes
' 10 MB = 10485760 Bytes
' 100 MB = 104857600 Bytes
' If file size is greater then 2 MB in either Selection Criteria or CV then stop upload and display error message.
If Upload("File1").Length > 2097152 or Upload("File2").Length > 2097152 Then
' Notify user of the error.
Response.Write "File size of each attachment must be in 2mb or less in the following formats"
' Stop all execution past this line.
Response.End
End If
' This is where you upload to
Folder = Server.MapPath("\file_bin") & "\"
' Grab the file names from the form, these are used in the Mail Procedure
FileName1 = Upload.Fields("sc_file").FileName
FileName2 = Upload.Fields("cv_file").FileName
' Upload the file names to set folder on sever
Upload("sc_file").SaveAs Folder & Upload("sc_file").FileName
Upload("cv_file").SaveAs Folder & Upload("cv_file").FileName
'-----------------------------------------------------------------
' Mail Procedure
'-----------------------------------------------------------------
Set objMail=CreateObject("CDO.Message")
objMail.Subject = strSubject
objMail.From = strFromEmail
objMail.To = cTo
'objMail.Cc = cCC
objMail.AddAttachment Folder & FileName1
objMail.AddAttachment Folder & FileName2
objMail.HTMLBody = strMessage
If LiveWeb = "False" Then
'' Config fields for Live environment
'objMail.Configuration.Fields.Update
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'Name or IP of remote SMTP server
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
="10.1.1.12"
'Server port
objMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") _
=25
objMail.Send
Else
objMail.Send
End If
'-----------------------------------------------------------------
' Clean up procedures
'-----------------------------------------------------------------
'Delete files from server and close objects
Set file1 = fso.GetFile(Folder & FileName1)
Set file2 = fso.GetFile(Folder & FileName2)
file1.Delete
file2.Delete
' Close off objects
set objMail = nothing
set Upload = Nothing
set file1 = Nothing
set file2 = Nothing
set fso = Nothing
Response.Redirect(strRedirect)
%>
Last edited by Phil_work : April 24th, 2008 at 04:22 AM.
|