Hi, I have been using the following code for my contact us page where visitors fill up information and I receive the same in our email. Now I want the visitors to add an attachment along with the information they are sending through the form. Can you provide me the necessary code to be incorporated in the existing code. Also the file type for attachment will be only .txt or .doc or .rtf and also want to limit the size of the attachment. Please help me out. <html> <head> <head> <title>application</title> </head> <body> <% Response.Buffer = True Dim sMsg Dim sTo Dim sFrom Dim sSubject Dim sTextBody Dim sHTMLBody sTo = "abc@abc.com" sFrom = Request.Form("email") sSubject = "Application" sHTMLBody = "<h2>Application</h2>" sHTMLBody = sHTMLBody & "<br><br><b>Name: </b>" & Request.Form("name") sHTMLBody = sHTMLBody & "<br><br><b>Email: </b>" & Request.Form("email") Set objMail = Server.CreateObject("CDO.Message") Set objCDOSYSCon = Server.CreateObject ("CDO.Configuration") objCDOSYSCon.Fields("(URL address)") = "mail.abc.com" objCDOSYSCon.Fields("(URL address)") = 25 objCDOSYSCon.Fields("(URL address)") = 2 objCDOSYSCon.Fields("(URL address)") = 60 objCDOSYSCon.Fields.Update Set objMail.Configuration = objCDOSYSCon objMail.From = sFrom objMail.To = sTo objMail.Subject= sSubject objMail.HTMLBody = sHTMLBody objMail.Send Set objMail = Nothing Response.Redirect("thanks.html") %> </body> </html> Code (markup):
You may need addional code if your sending visitors have to upload any files to attach , but this is the basic concept used by CDOSYS <% Set myMail=CreateObject("CDO.Message") myMail.Subject="Sending email with CDO" myMail.From="mymail@mydomain.com" myMail.To="someone@somedomain.com" myMail.TextBody="This is a message." myMail.AddAttachment "c:\mydocuments\test.txt" myMail.Send set myMail=nothing %>
Thanks for your reply. myMail.AddAttachment "c:\mydocuments\test.txt" ----- but this is for sending attachment to users, is it not? Because when the visitors will be attaching a file through form the path of the file is not known to us and the asp file should have the provison to map the path of the file.
No, you cannot send it directly from their PC. You will have to upload the file first so it is on your server and then once it is there it can be attached to the email as above and then sent.