![]() |
||||
|
<% 'check if form has been posted or if this is just the first page view if request.QueryString("up") = "1" then dim Upload, maxbytes maxbytes = 500000 Set Upload = Server.CreateObject("Persits.Upload.1") ' Save to disk 'Upload.Save server.MapPath("uploaded/") Upload.SaveVirtual("uploaded/") %> <% Private sub deleteFile(filespec) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") if fso.FileExists(filespec) then fso.DeleteFile filespec, true end if Set fso = Nothing End sub Function returnFileName(pth) dim fso Set fso = CreateObject("Scripting.FileSystemObject") returnFileName = fso.getFileName(pth) set fso = Nothing End Function Private Sub moveFile(src, dest) Dim fso Set fso = CreateObject("Scripting.FileSystemObject") if fso.FileExists(dest) then ' fso.DeleteFile dest, true end if fso.MoveFile src, dest Set fso = Nothing End Sub Dim MyCDONTSMail Set MyCDONTSMail = CreateObject("CDONTS.NewMail") MyCDONTSMail.From= "wayne@igbh.com" MyCDONTSMail.To= "wayne@igbh.com" MyCDONTSMail.To= "WAYNE@GLOBALSEARCHINT.COM" MyCDONTSMail.Subject="Enquiry from a customer" mainMessage= "First name: " + Upload.Form("firstname") + VBNewLine mainMessage= mainMessage + "Last name: " + Upload.Form("lastname") + VBNewLine mainMessage= mainMessage + "Contact number: " + Upload.Form("contactnumber") + VBNewLine mainMessage= mainMessage + "Email address: " + Upload.Form("emailaddress") + VBNewLine mainMessage= mainMessage + "Additional Information: " + VBNewLine + Upload.Form("additionalinformation") + VBNewLine MyCDONTSMail.Body= mainMessage response.Write " Client Enquiry " response.Write " Thank you for submitting the form. We will be in touch soon. " For Each File in Upload.Files filename = returnFileName(File.Path) SELECT CASE LCase(right(File.Path, 4)) CASE ".doc" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ".jpg" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ".jif" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ".bmp" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ".xls" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ".ppt" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ".pub" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ".pdf" if File.Size < maxbytes then sendMail = true MyCDONTSMail.AttachFile File.Path ' I left the line below out. ' Response.Write filename & " (" & File.Size &" bytes) was sent. " else Response.Write "Error: " & filename & " exceeded the maximum file size of " & maxbytes & " bytes. " Response.Write "Your file has not been sent with the form. Please try again with a correct sized file. " Response.Write "GO BACK" end if CASE ELSE Response.Write "Error: File '" & filename & "' was not of a valid type. " Response.Write "Please only submit files ending with .jpg, .jif, .bmp, .xls, .ppt, .doc, .pub or .pdf. " Response.Write "Your file has not been sent with the form. Please try again with a correct file. " Response.Write "GO BACK" END SELECT next sendMail = true Dim MyCDONTSMailToSender Set MyCDONTSMailToSender = CreateObject("CDONTS.NewMail") MyCDONTSMailToSender.From= "wayne@igbh.com" MyCDONTSMailToSender.To= Upload.Form("emailaddress") MyCDONTSMailToSender.Subject="Thanks for submitting your details to IGBH" messageToSender = Upload.Form("firstname") + ", thanks for submitting your details." + VBNewLine + VBNewLine messageToSender = messageToSender + "We will be in contact with you soon." + VBNewLine + VBNewLine messageToSender = messageToSender + "Management" + VBNewLine + VBNewLine MyCDONTSMailToSender.Body = messageToSender if sendmail = true then MyCDONTSMail.Send set MyCDONTSMail=nothing MyCDONTSMailToSender.Send set MyCDONTSMailToSender = nothing end if 'clean up server AFTER mail is sent for each File in upload.Files deleteFile File.Path next Set Upload = Nothing else %> Client Enquiry If you require further information about our services, or are seeking candidtates to fulfil a role, please contact us or use the enquiry form below. <% end if %> |
|
||
|
||||