SunQuest
           ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old April 24th, 2008, 04:19 AM
Phil_work Phil_work is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Canberra, Australia
Posts: 317 Phil_work User rank is Corporal (100 - 500 Reputation Level)Phil_work User rank is Corporal (100 - 500 Reputation Level)Phil_work User rank is Corporal (100 - 500 Reputation Level)Phil_work User rank is Corporal (100 - 500 Reputation Level) 
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.

Reply With Quote
  #2  
Old April 25th, 2008, 01:05 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,711 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 21 m 59 sec
Reputation Power: 688
Quote:
Can anyone see anything wrong with the script, that would cause this error?
Nope, but I really didn't even look at the code. However, if you pointed out line 151 and provided the complete error message instead of just "fails" you might get better answers.
__________________
======
Doug G
======
"Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton

Reply With Quote
  #3  
Old April 25th, 2008, 01:26 AM
Phil_work Phil_work is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Location: Canberra, Australia
Posts: 317 Phil_work User rank is Corporal (100 - 500 Reputation Level)Phil_work User rank is Corporal (100 - 500 Reputation Level)Phil_work User rank is Corporal (100 - 500 Reputation Level)Phil_work User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 19 h 42 m 18 sec
Reputation Power: 7
Quote:
Originally Posted by Doug G
Nope, but I really didn't even look at the code. However, if you pointed out line 151 and provided the complete error message instead of just "fails" you might get better answers.


Thanks.

Error message:
CDO.Message.1 error '80070002'
The system cannot find the file specified.
/mail_scripts/cp_apply.asp, line 151

Line 151: objMail.AddAttachment Folder & FileName1

Reply With Quote
  #4  
Old April 25th, 2008, 10:17 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,711 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 21 m 59 sec
Reputation Power: 688
Add a debug probe to test your values, something like
Code:
response.write Folder & FileName1
response.end
This will write the filename argument to your browser and you can verify it's correct. Don't forget to take out the debug code when you have it fixed.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > ASP Send mail


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway