Hi,
Is there anyone who can help me to embed a file attachment script in this contact form?
I want to add a field for file attachment in this contact form
Here is the script for both files:
contactus.html
========================================
:: CONTACT FORM ::
"
Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration")
'Out going SMTP server
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.mydomain.com" 'Insert your SMTP server address
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "info@mydomain.com"
objCDOSYSCon.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "123456"
objCDOSYSCon.Fields.Update
Set ObjSendMail = Server.CreateObject("CDO.Message")
'Update the CDOSYS Configuration
Set ObjSendMail.Configuration = objCDOSYSCon
ObjSendMail.From ="info@mydomain.com"
ObjSendMail.To = Request.Form("text5")
ObjSendMail.cc = "info@mydomain.com"
ObjSendMail.Subject = Request.Form("Subject")
''Response.Write "file://" & Request.Form("attachfile")
dim arr,i,strvalue
arr=Split(Request.Form("attachfile"),"\")
for i=0 to ubound(arr)
if i=ubound(arr) then
strvalue= arr(i)
end if
next
''Response.Write Request.Form("attachfile")`
''ObjSendMail.Attachments(1)= ".\" & strvalue
ObjSendMail.AddAttachment(Request.Form("attachfile"))
ObjSendMail.HTMLBody = msg
ObjSendMail.Send
If Err.Number <> 0 Then
Response.Write "Error encountered: " & Err.Description
else
Response.Write "Mail Sent"
End If
Set ObjSendMail = Nothing
Response.Redirect("Thanks.html")
%>
==========================================================
Thanks
Zap Infotech
www.zapinfotech.com
www.registrar4domain.com
Posted by Dwagar, 09-02-2008, 02:05 AM
In ASP you would need a upload component to put the file on the server then after the email is sent you can delete the uploaded file. Do you have a component? You can do it in pure ASP but its not that liable. With the following line that you have in the ASP code you provided you will just need the path on the server that the file is located.
ObjSendMail.AddAttachment(Request.Form("attachfile"))
That looks like it should work out for you.