ric73
10-12-2006, 10:51 AM
Hello,
I am creating a form that sends an email with some text fields and allows the user to choose a file from his computer and attach it to the email and send it to my web server. I receive the email with all the text fields but the attachement field is just the file location and not the file!
I am using FORM method="post" and I have tried to use enctype="multipart/form-data" with INPUT type="file" but then I do not receive anything at all.
Does my server not support the enctype attribute am I doing something wrong in the ASP code I send:
Sub SendContactEmail()
Dim strFrom
Dim strTo
Dim strSubject
Dim strBody
strFrom = Request.Form("Name") & " <" & ValidateFrom(Request.Form("EMail")) & ">"
strTo = "email@email.com"
strSubject = "Contact"
strBody = _
"Name: " & Request.Form("Name") & vbCrLf & _
"Telephone: " & Request.Form("Telephone") & vbCrLf & _
"EMail: " & Request.Form("EMail") & vbCrLf & _
"Architect: " & Request.Form("Architect") & vbCrLf & _
"Year Built: " & Request.Form("Year") & vbCrLf & _
"Location: " & Request.Form("Location") & vbCrLf & _
"Country: " & Request.Form("Country") & vbCrLf & _
"File: " & Request.Form("filefield") & vbCrLf & _
"Comments: " & Request.Form("Comments") & vbCrLf
EmailText strFrom, strTo, "", strSubject, strBody
End Sub
The form code is as follows without the enctype:
<FORM method="post" class="ContactField">
<DIV class="ContactLabel">Name:</DIV>
<DIV><INPUT type="text" name="Name" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Telephone:</DIV>
<DIV><INPUT type="text" name="Telephone" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">EMail:</DIV>
<DIV><INPUT type="text" name="EMail" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Architect:</DIV>
<DIV><INPUT type="text" name="Architect" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Year Built:</DIV>
<DIV><INPUT type="text" name="Year" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Location:</DIV>
<DIV><INPUT type="text" name="Location" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Country:</DIV>
<DIV><INPUT type="text" name="Country" class="ContactField" size="20"></DIV>-->
<DIV class="ContactLabel">Upload Image:</DIV>
<DIV><input type="file" name="filefield" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Comments:</DIV>
<DIV><TEXTAREA name="Comments" class="ContactField" scroll="auto" rows="1" cols="20"></TEXTAREA></DIV>
<DIV class="ContactSubmit"><INPUT type="image" src="/images/submit-acc.gif" width="87" height="17" align="middle"></DIV>
<DIV class="ContactNote">NOTE: Your information will never be shared with a third party!</DIV>
</FORM>
I am getting desperate! Can anyone help? THANK YOU
I am creating a form that sends an email with some text fields and allows the user to choose a file from his computer and attach it to the email and send it to my web server. I receive the email with all the text fields but the attachement field is just the file location and not the file!
I am using FORM method="post" and I have tried to use enctype="multipart/form-data" with INPUT type="file" but then I do not receive anything at all.
Does my server not support the enctype attribute am I doing something wrong in the ASP code I send:
Sub SendContactEmail()
Dim strFrom
Dim strTo
Dim strSubject
Dim strBody
strFrom = Request.Form("Name") & " <" & ValidateFrom(Request.Form("EMail")) & ">"
strTo = "email@email.com"
strSubject = "Contact"
strBody = _
"Name: " & Request.Form("Name") & vbCrLf & _
"Telephone: " & Request.Form("Telephone") & vbCrLf & _
"EMail: " & Request.Form("EMail") & vbCrLf & _
"Architect: " & Request.Form("Architect") & vbCrLf & _
"Year Built: " & Request.Form("Year") & vbCrLf & _
"Location: " & Request.Form("Location") & vbCrLf & _
"Country: " & Request.Form("Country") & vbCrLf & _
"File: " & Request.Form("filefield") & vbCrLf & _
"Comments: " & Request.Form("Comments") & vbCrLf
EmailText strFrom, strTo, "", strSubject, strBody
End Sub
The form code is as follows without the enctype:
<FORM method="post" class="ContactField">
<DIV class="ContactLabel">Name:</DIV>
<DIV><INPUT type="text" name="Name" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Telephone:</DIV>
<DIV><INPUT type="text" name="Telephone" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">EMail:</DIV>
<DIV><INPUT type="text" name="EMail" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Architect:</DIV>
<DIV><INPUT type="text" name="Architect" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Year Built:</DIV>
<DIV><INPUT type="text" name="Year" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Location:</DIV>
<DIV><INPUT type="text" name="Location" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Country:</DIV>
<DIV><INPUT type="text" name="Country" class="ContactField" size="20"></DIV>-->
<DIV class="ContactLabel">Upload Image:</DIV>
<DIV><input type="file" name="filefield" class="ContactField" size="20"></DIV>
<DIV class="ContactLabel">Comments:</DIV>
<DIV><TEXTAREA name="Comments" class="ContactField" scroll="auto" rows="1" cols="20"></TEXTAREA></DIV>
<DIV class="ContactSubmit"><INPUT type="image" src="/images/submit-acc.gif" width="87" height="17" align="middle"></DIV>
<DIV class="ContactNote">NOTE: Your information will never be shared with a third party!</DIV>
</FORM>
I am getting desperate! Can anyone help? THANK YOU