TrueBlue
asked on
Form generates error and no attachment
Hi!
Our web hosting company stopped supporting CDONTs.
So we are trying to implement CDOSYS.
Our original form used CDONTs and ASPUpload to send an attachment.
As you can see we are still using the ASPUpload not sure if needed or not?
Currently, using FF version 19.0.2 an email is generated with no attachment.
The attachment is however stored in the upload directory on the server.
Using IE 10 we just get an error '8004020f' /sendeform.asp, line 99
Line 99 is ObjSendMail.Send
So obviously we have a problem with this line...
if len(Filename) > 0 then
objSendMail.AddAttachment Server.MapPath(Upload.Form ("FilePath ")) & "\" & Filename
end if
Not sure what else.
Any specific code corrections would greatly appreciated.
I am sure the server.mappath is correct not sure what equivalent of upload.form("FilePath")
is in CDOSYS
.
Here is our current attempt:
<%@ Language=VBScript%>
<%Response.buffer=true%>
<%
sAllow = "bmp,doc,docx,gif,jpg,pdf, png"
Set Upload = Server.CreateObject("Persi ts.Upload" )
' Limit file size to 100000 bytes, throw an exception if file is larger
Upload.SetMaxSize 100000, True
Upload.SaveToMemory
For Each File in Upload.Files
Ext = Lcase(Right(strFileName, 3))
strFileName = Lcase(File.FileName)
'test=Server.MapPath(Uploa d.Form("Fi lePath") & "\" & strFilename)
'response.write test ' just for testing
'response.end() ' just for testing
If instr(sAllow, Ext) Then
File.SaveAs(Server.MapPath (Upload.Fo rm("FilePa th") & "\" & strFilename))
End If
Next
%>
<!-- Include file for CAPTCHA form processing -->
<!-- #include file="CAPTCHA/new_CAPTCHA_ process_fo rm.asp" -->
<%
If "" & Upload.Form("EmailAddress" ) <> "" Then
'blnCAPTCHAcodeCorrect = Upload.Form("CAPTCHA_Postb ack")
'response.write blnCAPTCHAcodeCorrect
'response.write Upload.Form("EmailAddress" )
'response.end
If blnCAPTCHAcodeCorrect <> True then
Session("Name") = Upload.Form("Name")
Session("EmailAddress") = Upload.Form("EmailAddress" )
Session("DaytimePhone") = Upload.Form("DaytimePhone" )
Session("Subject") = Upload.Form("Subject")
Session("StreetAddress") = Upload.Form("StreetAddress ")
Session("City") = Upload.Form("City")
Session("State") = Upload.Form("State")
Session("ZipCode") = Upload.Form("ZipCode")
Session("Message") = Upload.Form("Message")
'response.write Session("Message")
'response.end
Response.Redirect "contact-us.asp?err=captch a"
Else
strBody = "<!DOCTYPE HTML PUBLIC ""-/W3C//DTD HTML 4.0 Transitional//EN"">" _
& "<html>" _
& "<head>" _
& "<title>" & Upload.Form("Subject") & "</title>" _
& "<meta http-equiv=Content-Type content=""text/html; charset=iso=8859-1"">" _
& "</head>" _
& "<body bgcolor=""#FFFF99"">" _
& "<h2>" & Upload.Form("Subject") & "</h2>" & "<BR>" _
& "<p>" _
& "Name: " & Upload.Form("Name") & "<BR>" _
& "IP Address: " & Request.ServerVariables("R EMOTE_HOST ") & "<BR>" _
& "Daytime Phone No: " & Upload.Form("DaytimePhone" ) & "<BR>" _
& "Address: " & Upload.Form("StreetAddress ") & "<BR>" _
& "City: " & Upload.Form("City") & "<BR>" _
& "State: " & Upload.Form("State") & "<BR>" _
& "Zip Code: " & Upload.Form("ZipCode") & "<BR>" _
& "Message: " & Upload.Form("Message") & "<BR>" _
& "</p>" & "<BR>" _
& "</body>" & "<BR>" _
& "</html>" & "<BR>"
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message" )
' This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.mydomain.com"
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 587
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="techserv@mydomain.com"
ObjSendMail.Configuration. Fields.Ite m ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="xxxxxx"
ObjSendMail.Configuration. Fields.Upd ate
' End remote SMTP server configuration section==
' Set the properties of the object
ObjSendMail.Subject = Upload.Form("Subject")
ObjSendMail.From = Upload.Form("EmailAddress" ) 'specify senders address
ObjSendMail.To = "techserv@mydomain.com"
' ObjSendMail.Cc = "sales@mydomain.com"
' Response.write Server.MapPath(Upload.Form ("FilePath ")) & "\" & Filename
if len(Filename) > 0 then
objSendMail.AddAttachment Server.MapPath(Upload.Form ("FilePath ")) & "\" & Filename
end if
ObjSendMail.HTMLBody = strbody
ObjSendMail.Send
Set ObjSendMail = Nothing
Response.Redirect("thankyo u.htm")
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
End If
Else %>
<script language="JavaScript" type="text/javascript">jav ascript: window.history.back(-1)</s cript>
<% End IF %>
Our web hosting company stopped supporting CDONTs.
So we are trying to implement CDOSYS.
Our original form used CDONTs and ASPUpload to send an attachment.
As you can see we are still using the ASPUpload not sure if needed or not?
Currently, using FF version 19.0.2 an email is generated with no attachment.
The attachment is however stored in the upload directory on the server.
Using IE 10 we just get an error '8004020f' /sendeform.asp, line 99
Line 99 is ObjSendMail.Send
So obviously we have a problem with this line...
if len(Filename) > 0 then
objSendMail.AddAttachment Server.MapPath(Upload.Form
end if
Not sure what else.
Any specific code corrections would greatly appreciated.
I am sure the server.mappath is correct not sure what equivalent of upload.form("FilePath")
is in CDOSYS
.
Here is our current attempt:
<%@ Language=VBScript%>
<%Response.buffer=true%>
<%
sAllow = "bmp,doc,docx,gif,jpg,pdf,
Set Upload = Server.CreateObject("Persi
' Limit file size to 100000 bytes, throw an exception if file is larger
Upload.SetMaxSize 100000, True
Upload.SaveToMemory
For Each File in Upload.Files
Ext = Lcase(Right(strFileName, 3))
strFileName = Lcase(File.FileName)
'test=Server.MapPath(Uploa
'response.write test ' just for testing
'response.end() ' just for testing
If instr(sAllow, Ext) Then
File.SaveAs(Server.MapPath
End If
Next
%>
<!-- Include file for CAPTCHA form processing -->
<!-- #include file="CAPTCHA/new_CAPTCHA_
<%
If "" & Upload.Form("EmailAddress"
'blnCAPTCHAcodeCorrect = Upload.Form("CAPTCHA_Postb
'response.write blnCAPTCHAcodeCorrect
'response.write Upload.Form("EmailAddress"
'response.end
If blnCAPTCHAcodeCorrect <> True then
Session("Name") = Upload.Form("Name")
Session("EmailAddress") = Upload.Form("EmailAddress"
Session("DaytimePhone") = Upload.Form("DaytimePhone"
Session("Subject") = Upload.Form("Subject")
Session("StreetAddress") = Upload.Form("StreetAddress
Session("City") = Upload.Form("City")
Session("State") = Upload.Form("State")
Session("ZipCode") = Upload.Form("ZipCode")
Session("Message") = Upload.Form("Message")
'response.write Session("Message")
'response.end
Response.Redirect "contact-us.asp?err=captch
Else
strBody = "<!DOCTYPE HTML PUBLIC ""-/W3C//DTD HTML 4.0 Transitional//EN"">" _
& "<html>" _
& "<head>" _
& "<title>" & Upload.Form("Subject") & "</title>" _
& "<meta http-equiv=Content-Type content=""text/html; charset=iso=8859-1"">" _
& "</head>" _
& "<body bgcolor=""#FFFF99"">" _
& "<h2>" & Upload.Form("Subject") & "</h2>" & "<BR>" _
& "<p>" _
& "Name: " & Upload.Form("Name") & "<BR>" _
& "IP Address: " & Request.ServerVariables("R
& "Daytime Phone No: " & Upload.Form("DaytimePhone"
& "Address: " & Upload.Form("StreetAddress
& "City: " & Upload.Form("City") & "<BR>" _
& "State: " & Upload.Form("State") & "<BR>" _
& "Zip Code: " & Upload.Form("ZipCode") & "<BR>" _
& "Message: " & Upload.Form("Message") & "<BR>" _
& "</p>" & "<BR>" _
& "</body>" & "<BR>" _
& "</html>" & "<BR>"
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message"
' This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.
ObjSendMail.Configuration.
ObjSendMail.Configuration.
ObjSendMail.Configuration.
ObjSendMail.Configuration.
' If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.
ObjSendMail.Configuration.
ObjSendMail.Configuration.
ObjSendMail.Configuration.
ObjSendMail.Configuration.
' End remote SMTP server configuration section==
' Set the properties of the object
ObjSendMail.Subject = Upload.Form("Subject")
ObjSendMail.From = Upload.Form("EmailAddress"
ObjSendMail.To = "techserv@mydomain.com"
' ObjSendMail.Cc = "sales@mydomain.com"
' Response.write Server.MapPath(Upload.Form
if len(Filename) > 0 then
objSendMail.AddAttachment Server.MapPath(Upload.Form
end if
ObjSendMail.HTMLBody = strbody
ObjSendMail.Send
Set ObjSendMail = Nothing
Response.Redirect("thankyo
If Err <> 0 Then
Response.Write "Error encountered: " & Err.Description
End If
End If
Else %>
<script language="JavaScript" type="text/javascript">jav
<% End IF %>
ASKER
padas,
I did find one thing I should have used strFilename, but even with your idea of the full pathname there still there is no attachment in the email that is generated.
I checked the server and the file is in the expected directory.
No errors are given.
Checked it with FF & IE 10.
Any other ideas?
I did find one thing I should have used strFilename, but even with your idea of the full pathname there still there is no attachment in the email that is generated.
I checked the server and the file is in the expected directory.
No errors are given.
Checked it with FF & IE 10.
Any other ideas?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
this is the line to change
objSendMail.AddAttachment Server.MapPath(Upload.Form