Knowledgebase

Need Help for file attachment in asp contact form

Posted by zapinfotech, 08-10-2008, 09:34 AM
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 ::
 
  Name
Address
Tel. No.
Mobile No.
E-mail
  Your Queries
  Attach file
      
contact-action.asp ======================================================== <% Dim ObjSendMail, objCDOSYSCon msg = "
Contact Form" msg = msg & "
" msg = msg & "


" msg = msg & "Name : " & Request.form("text1") & "
" msg = msg & "

" msg = msg & "Address : " & Request.form("text2") & "
" msg = msg & "

" msg = msg & "Telephone : " & Request.form("text3") & "
" msg = msg & "

" msg = msg & "Phone Number: " & Request.form("text4") & "
" msg = msg & "

" msg = msg & "Email : " & Request.form("text5") & "
" msg = msg & "

" msg = msg & "

" msg = msg & "Queries : " & Request.form("text6") & "
" msg = msg & "

" msg = msg & "

" msg = msg & "



" 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.

Posted by zapinfotech, 09-02-2008, 03:30 AM
thanks buddy



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article

Also Read
Geektorage [split] (Views: 662)
Cloud in Sweden? (Views: 634)


Language:

Client Login

Email

Password

Remember Me

Search