ASPUpload | ASPUpload Email Component Script by ASP Web Pro
  ASPUpload | ASPUpload Email Component Script

ASP Scripts

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:

<FORM method="Post" action="resultspage.asp" name="Recruiter">
<TABLE width="100%" border="0">
<TR><TD width="30%"><div align="right">Email:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="Email" size="50"></TD></TR>
<TR><TD width="30%"><div align="right">First Name:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="FirstName" size="50"></TD></TR>
<TR><TD width="30%"><div align="right">Last Name:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="LastName" size="50"></TD></TR>
<TR><TD width="30%"><div align="right">Position APPlying For:</div></TD>
<TD width="70%"><INPUT TYPE="text" name="Position" size="50"></TD></TR>
<TR> <TD width="30%"><div align="right">Resume:</div></TD>
<TD width="70%"><INPUT TYPE="file" name="Resume" size="35"></TD></TR>
<TR><TD width="30%" valign="top"><div align="right">Comments:</div></TD>
<TD width="70%"><textarea name="Comments" cols="50" rows="5"></textarea></TD></TR>
</TABLE>
<P>
<INPUT TYPE="submit" name="Submit" value="Submit">
<INPUT TYPE="reset" name="Reset" value="Reset">
</P>
</FORM>

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

<!--#INCLUDE VIRTUAL="/includes/connection.asp" -->

<%
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") & ",<br><br>"
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: <B>" & Err.Description & "</B>"
ELSE
Response.Write Upload.Form("FirstName") & ","
Response.Write "<p>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.</p>"
File.Delete
END IF
END IF
END IF

NEXT
%>

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

<P>Thank you for emailing us your resume.</P>

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.

< Back to ASP Scripts


 

 

Main Menu
Home
ASP Scripts
ASP Tutorials
JavaScripts
Awards
Contact Us

Email This Page

Other Resources
ASP Web Hosting
Search Engine Submission
Programming Help

 

 

 

Other ASP Web Sites

Site Map

 

Last Updated:
06 July 2008