Forums
This topic is locked
cannot add a form fiel to code
Posted 27 Apr 2005 23:54:42
1
has voted
27 Apr 2005 23:54:42 zack morris posted:
Hi,I cannot seem to add another form field to the following code without getting some error or the other. Can someone please instruct me on adding another form field to this.
Thankyou (see code below)
<%
' change to address of your own SMTP server
strHost = "mail.comtechnologies.com"
' We use AspUpload component to capture uploaded file and access other form items.
' Because of the special ENCTYPE attribute we can no longer use Request.Form,
' we must use Upload.Form instead.
' More more info on AspUpload, visit www.aspupload.com.
Set Upload = Server.CreateObject("Persits.Upload"

Upload.IgnoreNoPost = True
' capture an upload and save uploaded files (if any) in temp directory
Upload.Save "d:\web\mysite\Uploadedstuff\"
' We cannot use Upload.Form or Upload.Files until Upload.Save is called.
If Upload.Form("Send"

Set Mail = Server.CreateObject("Persits.MailSender"

Mail.From = " "
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject"

Mail.Body = Upload.Form("Body"

Mail.AddAddress Upload.Form("To"

' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment"

Mail.AddAttachment Upload.Files("Attachment"

End If
' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%>
Replies
Replied 29 Apr 2005 12:55:36
29 Apr 2005 12:55:36 Wayne Hultum replied:
Hi Zack,
I'm not sure what you mean by adding another form field to the code. The code below is a form processing script, so you can't add a form field the that script, you would have to add the fields the the form that uses the script.
regards
Wayne
Edited by - wayne1000 on 29 Apr 2005 12:57:45
I'm not sure what you mean by adding another form field to the code. The code below is a form processing script, so you can't add a form field the that script, you would have to add the fields the the form that uses the script.
regards
Wayne
Edited by - wayne1000 on 29 Apr 2005 12:57:45
Replied 29 Apr 2005 17:32:38
29 Apr 2005 17:32:38 zack morris replied:
Hi Wayne,
I want to add fields (2 fields to be specific) to the html form that sends data to this processing script. My issue is that I cannot figure out how to modify the processing script to accept the data from the newly added fields. The code for the HTML form I want to use with the processing script is pasted below. It currently gives an error, since the processing script cannot "see" the additional 2 fields which are (First Name, Last Name)
I do appreciate your help a lot,
Zack
<!-- Note special ENCTYPE attribute: it is necessary to upload a file-->
<FORM METHOD="POST" ACTION="UploadAttachment.asp" ENCTYPE="multipart/form-data">
<TABLE CELLSPACING=0 CELLPADDING=5>
<TR>
<TD>First Name:</TD>
<TD><input name="First Name" type="text" id="First Name"></TD>
</TR>
<TR>
<TD>Last Name:</TD>
<TD><input name="Last Name" type="text" id="Last Name"></TD>
</TR>
<TR><TD>Enter email:</TD><TD><INPUT TYPE="TEXT" NAME="To">
<input name="Subject" type="hidden" value="A candidate has submitted an application"></TD></TR>
<TR><TD valign="top">Enter Body:</TD>
<TD><TEXTAREA NAME="Body"></TEXTAREA></TD></TR>
<TR><TD>Select File Attachment:</TD><TD><INPUT TYPE=FILE NAME="Attachment"></TD></TR>
<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT NAME="Send" VALUE="Send"></TD></TR>
</TABLE>
</FORM>
----------------------------------------------
Hi Zack,
I'm not sure what you mean by adding another form field to the code. The code below is a form processing script, so you can't add a form field the that script, you would have to add the fields the the form that uses the script.
regards
Wayne
Edited by - wayne1000 on 29 Apr 2005 12:57:45
I want to add fields (2 fields to be specific) to the html form that sends data to this processing script. My issue is that I cannot figure out how to modify the processing script to accept the data from the newly added fields. The code for the HTML form I want to use with the processing script is pasted below. It currently gives an error, since the processing script cannot "see" the additional 2 fields which are (First Name, Last Name)
I do appreciate your help a lot,
Zack
<!-- Note special ENCTYPE attribute: it is necessary to upload a file-->
<FORM METHOD="POST" ACTION="UploadAttachment.asp" ENCTYPE="multipart/form-data">
<TABLE CELLSPACING=0 CELLPADDING=5>
<TR>
<TD>First Name:</TD>
<TD><input name="First Name" type="text" id="First Name"></TD>
</TR>
<TR>
<TD>Last Name:</TD>
<TD><input name="Last Name" type="text" id="Last Name"></TD>
</TR>
<TR><TD>Enter email:</TD><TD><INPUT TYPE="TEXT" NAME="To">
<input name="Subject" type="hidden" value="A candidate has submitted an application"></TD></TR>
<TR><TD valign="top">Enter Body:</TD>
<TD><TEXTAREA NAME="Body"></TEXTAREA></TD></TR>
<TR><TD>Select File Attachment:</TD><TD><INPUT TYPE=FILE NAME="Attachment"></TD></TR>
<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT NAME="Send" VALUE="Send"></TD></TR>
</TABLE>
</FORM>
----------------------------------------------
Hi Zack,
I'm not sure what you mean by adding another form field to the code. The code below is a form processing script, so you can't add a form field the that script, you would have to add the fields the the form that uses the script.
regards
Wayne
Edited by - wayne1000 on 29 Apr 2005 12:57:45
Replied 29 Apr 2005 18:26:49
29 Apr 2005 18:26:49 Wayne Hultum replied:
Hi Zack,
Try the code below, but make sure you have a backup of your old script first. I havent tried it because my host doesn't have Persits.MailSender installed. If you get any errors post them back and I'll try to help.
<pre id=code><font face=courier size=2 id=code><%
' change to address of your own SMTP server
strHost = "mail.comtechnologies.com"
Set Upload = Server.CreateObject("Persits.Upload"
Upload.IgnoreNoPost = True
' capture an upload and save uploaded files (if any) in temp directory
Upload.Save "d:\web\mysite\Uploadedstuff\"
strFirstName = upload.Form("First Name"
strLastName = upload.Form("Last Name"
strEmail = upload.Form("To"
strBody = upload.Form("body"
strSubject = upload.Form("Subject"
' We cannot use Upload.Form or Upload.Files until Upload.Save is called.
If Upload.Form("Send"
<> "" Then
Set Mail = Server.CreateObject("Persits.MailSender"
Mail.To = " "
Mail.From = " "
Mail.BodyFormat = "0" ' -- HTML format
Mail.MailFormat = "0" ' -- HTML format
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject"
mBody = "<html><head><style>body, td{font:12px Arial, Helvetica, sans-serif;}</style></head><body><table>" & vbCrLf _
& "<tr><td style=""width:150px"">Name:</td><td>" & Trim(strFirstName) & " "& Trim(strLastName) &"</td></tr><br>" & vbCrLf _
& "<tr><td>Email:</td><td> " & Trim(strEmail) & "<br></td></tr>" & vbCrLf _
& "<tr><td>Subject:</td><td> " & Trim(strSubject) & "<br></td></tr>" & vbCrLf _
& "<tr><td valign=top>Enquiry:</td><td> " & Replace(Trim(strBody), vbCrLf,"<br>"
& "<br></td></tr></table></body></html>"
'Mail.AddAddress Upload.Form("To"
' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment"
Is Nothing Then
Mail.AddAttachment Upload.Files("Attachment"
.Path
End If
Mail.Body = mBody
' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%> </font id=code></pre id=code>
Wayne
Try the code below, but make sure you have a backup of your old script first. I havent tried it because my host doesn't have Persits.MailSender installed. If you get any errors post them back and I'll try to help.
<pre id=code><font face=courier size=2 id=code><%
' change to address of your own SMTP server
strHost = "mail.comtechnologies.com"
Set Upload = Server.CreateObject("Persits.Upload"

Upload.IgnoreNoPost = True
' capture an upload and save uploaded files (if any) in temp directory
Upload.Save "d:\web\mysite\Uploadedstuff\"
strFirstName = upload.Form("First Name"

strLastName = upload.Form("Last Name"

strEmail = upload.Form("To"

strBody = upload.Form("body"

strSubject = upload.Form("Subject"

' We cannot use Upload.Form or Upload.Files until Upload.Save is called.
If Upload.Form("Send"

Set Mail = Server.CreateObject("Persits.MailSender"

Mail.To = " "
Mail.From = " "
Mail.BodyFormat = "0" ' -- HTML format
Mail.MailFormat = "0" ' -- HTML format
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject"

mBody = "<html><head><style>body, td{font:12px Arial, Helvetica, sans-serif;}</style></head><body><table>" & vbCrLf _
& "<tr><td style=""width:150px"">Name:</td><td>" & Trim(strFirstName) & " "& Trim(strLastName) &"</td></tr><br>" & vbCrLf _
& "<tr><td>Email:</td><td> " & Trim(strEmail) & "<br></td></tr>" & vbCrLf _
& "<tr><td>Subject:</td><td> " & Trim(strSubject) & "<br></td></tr>" & vbCrLf _
& "<tr><td valign=top>Enquiry:</td><td> " & Replace(Trim(strBody), vbCrLf,"<br>"

'Mail.AddAddress Upload.Form("To"

' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment"

Mail.AddAttachment Upload.Files("Attachment"

End If
Mail.Body = mBody
' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%> </font id=code></pre id=code>
Wayne
Replied 29 Apr 2005 18:42:24
29 Apr 2005 18:42:24 zack morris replied:
I am getting the following error:
Persits.Upload.1 error '800a0005'
The system cannot find the path specified.
/teis/test/aspupload/UploadAttachment.asp, line 7
Even though the path in line 7 which is Upload.Save "uploads" does indeed have the "uploads" directory with the proper permissions.
Do you think that the path needs to be written in a different way?
Thanks,
Zain
------------------------------------------
Hi Zack,
Try the code below, but make sure you have a backup of your old script first. I havent tried it because my host doesn't have Persits.MailSender installed. If you get any errors post them back and I'll try to help.
<pre id=code><font face=courier size=2 id=code><%
' change to address of your own SMTP server
strHost = "mail.comtechnologies.com"
Set Upload = Server.CreateObject("Persits.Upload"
Upload.IgnoreNoPost = True
' capture an upload and save uploaded files (if any) in temp directory
Upload.Save "d:\web\mysite\Uploadedstuff\"
strFirstName = upload.Form("First Name"
strLastName = upload.Form("Last Name"
strEmail = upload.Form("To"
strBody = upload.Form("body"
strSubject = upload.Form("Subject"
' We cannot use Upload.Form or Upload.Files until Upload.Save is called.
If Upload.Form("Send"
<> "" Then
Set Mail = Server.CreateObject("Persits.MailSender"
Mail.To = " "
Mail.From = " "
Mail.BodyFormat = "0" ' -- HTML format
Mail.MailFormat = "0" ' -- HTML format
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject"
mBody = "<html><head><style>body, td{font:12px Arial, Helvetica, sans-serif;}</style></head><body><table>" & vbCrLf _
& "<tr><td style=""width:150px"">Name:</td><td>" & Trim(strFirstName) & " "& Trim(strLastName) &"</td></tr><br>" & vbCrLf _
& "<tr><td>Email:</td><td> " & Trim(strEmail) & "<br></td></tr>" & vbCrLf _
& "<tr><td>Subject:</td><td> " & Trim(strSubject) & "<br></td></tr>" & vbCrLf _
& "<tr><td valign=top>Enquiry:</td><td> " & Replace(Trim(strBody), vbCrLf,"<br>"
& "<br></td></tr></table></body></html>"
'Mail.AddAddress Upload.Form("To"
' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment"
Is Nothing Then
Mail.AddAttachment Upload.Files("Attachment"
.Path
End If
Mail.Body = mBody
' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%> </font id=code></pre id=code>
Wayne
Persits.Upload.1 error '800a0005'
The system cannot find the path specified.
/teis/test/aspupload/UploadAttachment.asp, line 7
Even though the path in line 7 which is Upload.Save "uploads" does indeed have the "uploads" directory with the proper permissions.
Do you think that the path needs to be written in a different way?
Thanks,
Zain
------------------------------------------
Hi Zack,
Try the code below, but make sure you have a backup of your old script first. I havent tried it because my host doesn't have Persits.MailSender installed. If you get any errors post them back and I'll try to help.
<pre id=code><font face=courier size=2 id=code><%
' change to address of your own SMTP server
strHost = "mail.comtechnologies.com"
Set Upload = Server.CreateObject("Persits.Upload"

Upload.IgnoreNoPost = True
' capture an upload and save uploaded files (if any) in temp directory
Upload.Save "d:\web\mysite\Uploadedstuff\"
strFirstName = upload.Form("First Name"

strLastName = upload.Form("Last Name"

strEmail = upload.Form("To"

strBody = upload.Form("body"

strSubject = upload.Form("Subject"

' We cannot use Upload.Form or Upload.Files until Upload.Save is called.
If Upload.Form("Send"

Set Mail = Server.CreateObject("Persits.MailSender"

Mail.To = " "
Mail.From = " "
Mail.BodyFormat = "0" ' -- HTML format
Mail.MailFormat = "0" ' -- HTML format
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject"

mBody = "<html><head><style>body, td{font:12px Arial, Helvetica, sans-serif;}</style></head><body><table>" & vbCrLf _
& "<tr><td style=""width:150px"">Name:</td><td>" & Trim(strFirstName) & " "& Trim(strLastName) &"</td></tr><br>" & vbCrLf _
& "<tr><td>Email:</td><td> " & Trim(strEmail) & "<br></td></tr>" & vbCrLf _
& "<tr><td>Subject:</td><td> " & Trim(strSubject) & "<br></td></tr>" & vbCrLf _
& "<tr><td valign=top>Enquiry:</td><td> " & Replace(Trim(strBody), vbCrLf,"<br>"

'Mail.AddAddress Upload.Form("To"

' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment"

Mail.AddAttachment Upload.Files("Attachment"

End If
Mail.Body = mBody
' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%> </font id=code></pre id=code>
Wayne
Replied 29 Apr 2005 18:48:07
29 Apr 2005 18:48:07 Wayne Hultum replied:
Try this
uploadPath = server.mappath("."
& "/path to folder on server"
Upload.Save = uploadPath
uploadPath = server.mappath("."

Upload.Save = uploadPath
Replied 29 Apr 2005 18:53:11
29 Apr 2005 18:53:11 zack morris replied:
The Path issue seems to be resolved but now it gives the error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'Mail.To'
site/sendmail.asp, line 16
-----------------------------------------------------------
I am getting the following error:
Persits.Upload.1 error '800a0005'
The system cannot find the path specified.
/teis/test/aspupload/UploadAttachment.asp, line 7
Even though the path in line 7 which is Upload.Save "uploads" does indeed have the "uploads" directory with the proper permissions.
Do you think that the path needs to be written in a different way?
Thanks,
Zain
------------------------------------------
Hi Zack,
Try the code below, but make sure you have a backup of your old script first. I havent tried it because my host doesn't have Persits.MailSender installed. If you get any errors post them back and I'll try to help.
<pre id=code><font face=courier size=2 id=code><%
' change to address of your own SMTP server
strHost = "mail.comtechnologies.com"
Set Upload = Server.CreateObject("Persits.Upload"
Upload.IgnoreNoPost = True
' capture an upload and save uploaded files (if any) in temp directory
Upload.Save "d:\web\mysite\Uploadedstuff\"
strFirstName = upload.Form("First Name"
strLastName = upload.Form("Last Name"
strEmail = upload.Form("To"
strBody = upload.Form("body"
strSubject = upload.Form("Subject"
' We cannot use Upload.Form or Upload.Files until Upload.Save is called.
If Upload.Form("Send"
<> "" Then
Set Mail = Server.CreateObject("Persits.MailSender"
Mail.To = " "
Mail.From = " "
Mail.BodyFormat = "0" ' -- HTML format
Mail.MailFormat = "0" ' -- HTML format
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject"
mBody = "<html><head><style>body, td{font:12px Arial, Helvetica, sans-serif;}</style></head><body><table>" & vbCrLf _
& "<tr><td style=""width:150px"">Name:</td><td>" & Trim(strFirstName) & " "& Trim(strLastName) &"</td></tr><br>" & vbCrLf _
& "<tr><td>Email:</td><td> " & Trim(strEmail) & "<br></td></tr>" & vbCrLf _
& "<tr><td>Subject:</td><td> " & Trim(strSubject) & "<br></td></tr>" & vbCrLf _
& "<tr><td valign=top>Enquiry:</td><td> " & Replace(Trim(strBody), vbCrLf,"<br>"
& "<br></td></tr></table></body></html>"
'Mail.AddAddress Upload.Form("To"
' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment"
Is Nothing Then
Mail.AddAttachment Upload.Files("Attachment"
.Path
End If
Mail.Body = mBody
' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%> </font id=code></pre id=code>
Wayne
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'Mail.To'
site/sendmail.asp, line 16
-----------------------------------------------------------
I am getting the following error:
Persits.Upload.1 error '800a0005'
The system cannot find the path specified.
/teis/test/aspupload/UploadAttachment.asp, line 7
Even though the path in line 7 which is Upload.Save "uploads" does indeed have the "uploads" directory with the proper permissions.
Do you think that the path needs to be written in a different way?
Thanks,
Zain
------------------------------------------
Hi Zack,
Try the code below, but make sure you have a backup of your old script first. I havent tried it because my host doesn't have Persits.MailSender installed. If you get any errors post them back and I'll try to help.
<pre id=code><font face=courier size=2 id=code><%
' change to address of your own SMTP server
strHost = "mail.comtechnologies.com"
Set Upload = Server.CreateObject("Persits.Upload"

Upload.IgnoreNoPost = True
' capture an upload and save uploaded files (if any) in temp directory
Upload.Save "d:\web\mysite\Uploadedstuff\"
strFirstName = upload.Form("First Name"

strLastName = upload.Form("Last Name"

strEmail = upload.Form("To"

strBody = upload.Form("body"

strSubject = upload.Form("Subject"

' We cannot use Upload.Form or Upload.Files until Upload.Save is called.
If Upload.Form("Send"

Set Mail = Server.CreateObject("Persits.MailSender"

Mail.To = " "
Mail.From = " "
Mail.BodyFormat = "0" ' -- HTML format
Mail.MailFormat = "0" ' -- HTML format
Mail.FromName = "Attachment Demo"
Mail.Host = strHost
Mail.Subject = Upload.Form("Subject"

mBody = "<html><head><style>body, td{font:12px Arial, Helvetica, sans-serif;}</style></head><body><table>" & vbCrLf _
& "<tr><td style=""width:150px"">Name:</td><td>" & Trim(strFirstName) & " "& Trim(strLastName) &"</td></tr><br>" & vbCrLf _
& "<tr><td>Email:</td><td> " & Trim(strEmail) & "<br></td></tr>" & vbCrLf _
& "<tr><td>Subject:</td><td> " & Trim(strSubject) & "<br></td></tr>" & vbCrLf _
& "<tr><td valign=top>Enquiry:</td><td> " & Replace(Trim(strBody), vbCrLf,"<br>"

'Mail.AddAddress Upload.Form("To"

' Handle attached file via Upload.Files collection.
' Check if a file was ineed uploaded
If Not Upload.Files("Attachment"

Mail.AddAttachment Upload.Files("Attachment"

End If
Mail.Body = mBody
' We are done. Send message
Mail.Send
Response.Write "Success!"
End If
%> </font id=code></pre id=code>
Wayne
Replied 29 Apr 2005 19:02:17
29 Apr 2005 19:02:17 Wayne Hultum replied:
try putting
dim Mail
above the Set Mail = Server.CreateObject("Persits.MailSender"
so it reads
dim Mail
Set Mail = Server.CreateObject("Persits.MailSender"
and changing mail.to to
Mail.AddAddress "youremailaddress"
Edited by - wayne1000 on 29 Apr 2005 19:09:40
dim Mail
above the Set Mail = Server.CreateObject("Persits.MailSender"

so it reads
dim Mail
Set Mail = Server.CreateObject("Persits.MailSender"

and changing mail.to to
Mail.AddAddress "youremailaddress"
Edited by - wayne1000 on 29 Apr 2005 19:09:40
Replied 29 Apr 2005 19:16:53
29 Apr 2005 19:16:53 zack morris replied:
Correction to previous posting:
The error reads and not waht I posted just before:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'AddAddress'
/teis/test/aspupload/UploadAttachment.asp, line 17
----------------------
try putting
dim Mail
above the Set Mail = Server.CreateObject("Persits.MailSender"
so it reads
dim Mail
Set Mail = Server.CreateObject("Persits.MailSender"
and changing mail.to to
Mail.AddAddress "youremailaddress"
Edited by - wayne1000 on 29 Apr 2005 19:09:40
The error reads and not waht I posted just before:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'AddAddress'
/teis/test/aspupload/UploadAttachment.asp, line 17
----------------------
try putting
dim Mail
above the Set Mail = Server.CreateObject("Persits.MailSender"

so it reads
dim Mail
Set Mail = Server.CreateObject("Persits.MailSender"

and changing mail.to to
Mail.AddAddress "youremailaddress"
Edited by - wayne1000 on 29 Apr 2005 19:09:40
Replied 29 Apr 2005 19:26:56
29 Apr 2005 19:26:56 Wayne Hultum replied:
It my be worth your while looking here www.aspemail.com/manual_02.html
Has the script ever been working? Just asking incase your host hasn't got AspEmail installed
Edited by - wayne1000 on 29 Apr 2005 19:28:54
Has the script ever been working? Just asking incase your host hasn't got AspEmail installed
Edited by - wayne1000 on 29 Apr 2005 19:28:54
Replied 29 Apr 2005 19:30:33
29 Apr 2005 19:30:33 zack morris replied:
Thank you so much for your help Wayne
Best regards,
Zain
----------------
It my be worth your while looking here www.aspemail.com/manual_02.html
Has the script ever been working? Just asking incase your host hasn't got AspEmail installed
Edited by - wayne1000 on 29 Apr 2005 19:28:54
Best regards,
Zain
----------------
It my be worth your while looking here www.aspemail.com/manual_02.html
Has the script ever been working? Just asking incase your host hasn't got AspEmail installed
Edited by - wayne1000 on 29 Apr 2005 19:28:54