Tuesday, 29 November 2011

ASPUpload

Another common task on the Internet is allowing users to send you file attachments. You can do this quickly and easily with the ASPUpload email component, which is supported by many ISP's. For example, if you have an employment page in your website, you might want to allow your users to send their resumes to you with an online form. Here is how you do it.


The server hosting your web site must have the ASPUpload component installed on it for this script to work. You can purchase the ASPUpload component online from www.aspupload.com.

The first thing you need to do is create an employment.asp page with the code below:

Email:
First Name:
Last Name:
Position APPlying For:
Resume:
Comments:




Next, you create a resultspage.asp page with our ASPUpload code as seen below:



<% DIM objRSr, File, Upload, Count, Ext DIM Mail, strMsgHeader Set Upload = Server.CreateObject("Persits.Upload.1") Count = Upload.SaveVirtual("/contactus/hr/upload/") IF NOT Count=0 THEN FOR EACH File IN Upload.Files Ext = UCase(Right(File.Path, 3)) IF Ext <> "TXT" AND Ext <> "DOC" THEN
Response.Write Upload.Form("FirstName") & ",

"
Response.Write "Sorry, your resume " & File.Path & " is not in a .DOC or .TXT format and has not been delivered through our system. Please save your resume in one of these formats and resubmit it."
File.Delete
ELSE

Set objRSr = Server.CreateObject("ADODB.Recordset")
objRSr.Open "tblContact", objConn, , adLockOptimistic, adCmdTable

objRSr.AddNew
objRSr("Data") = "Resumes"
objRSr("Email") = Upload.Form("Email")
objRSr("FirstName") = Upload.Form("FirstName")
objRSr("LastName") = Upload.Form("LastName")
objRSr("Position") = Upload.Form("Position")
objRSr("Comments") = Upload.Form("Comments")
objRSr("DateSubmitted") = Date()
Set File = Upload.Files("fResume")
If Not File Is Nothing Then objRSr("fResume").Value = File.Binary
objRSr.Update

objRSr.Close
Set objRSr = Nothing


Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "mail.YOUR_DOMAIN_NAME_HERE.com"
Mail.From = Upload.Form("Email")
Mail.AddAddress "YOUR_EMAIL_ADDRESS_HERE"
Mail.Subject = "Resume"
strMsgHeader = "This email was delivered from your website." & vbCrLf & vbCrLf
Mail.Body = strMsgHeader & "Email: " & Upload.Form("Email") & vbCrLf & "First Name: " & Upload.Form("FirstName") & vbCrLf & "Last Name: " & Upload.Form("LastName") & vbCrLf & "Position: " & Upload.Form("Position") & vbCrLf & vbCrLf & "Comments: " & Upload.Form("Comments")

IF Count > 0 THEN
Mail.AddAttachment Upload.Files(1).Path

On Error Resume Next
Mail.Send
IF Err <> 0 THEN
Response.Write "There was an error sending your message. Please visit our Contact Us page and send a message to our Webmaster to report this error: " & Err.Description & ""
ELSE
Response.Write Upload.Form("FirstName") & ","
Response.Write "

Thank you for contacting our recruiter. Your resume has been received and will be reviewed shortly. If we have a position is available that matches your skills, we will contact you to schedule an interview. We keep all resumes on file for a period of 6 months, please feel free to resubmit your resume after this time for future consideration.

"
File.Delete
END IF
END IF
END IF

NEXT
%>

<% ' This is a nice way to Personalize your FORM. ' It disPlays the Persons name before your message. strName = Request.Form("FirstName") Response.Write strFirstName %>,


Thank you for emailing us your resume.


There you have it. This script will allow your users to submit the form with or without an attachment. The script sends the form data by email and also stores it in your database. It even allows you to specify a file type like .TXT or .DOC, which we highly recommend using. Now, your web users can send you their resumes right from your web site.

http://www.aspwebpro.com/aspscripts/email/aspupload.asp

No comments:

Post a Comment