I am trying to attach a file to an email through CDO. This fill will be generated through a web based form. My company wants to put together a resume submission form to let people easily submit resumes for available positions. I am extremely new to scripting/coding and I would appreciate detailed help with this.
Per someone's suggestion I have been trying to use FileSystemObject and I have been unsuccessful. Every time I try to test the page on my computer it hangs and says "waiting for localhost".
Here is the script I am using:
<%
Dim objMail, objMailConf
Dim fs, fname
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set fname = Request.Form("resume")
fs.CopyFile fname, "c:\access\"
Set objMail = Server.CreateObject("CDO.Message")
Set objMailConf = Server.CreateObject("CDO.Configuration")
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.enter.net"
objMailConf.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMailConf.Fields.Update
Set objMail.Configuration = objMailConf
objMail.From = Request.Form("emailAddress")
objMail.To = "mail@mail.com"
objMail.Subject = Request.Form("emailSubject")
objMail.TextBody = Request.Form("emailText") & vbcrlf & "Home Phone Number: (" & Request.Form("homeArea") & ")" & Request.Form("homeNumber") & vbcrlf & "Cell Phone Number: (" & Request.Form("cellArea") & ")" & Request.Form("cellNumber")
objMail.AttachFile fname
objMail.Fields.Update
objMail.Send
Set objMail = Nothing
Set obMailConf = Nothing
Set fname = Nothing
Set fs = Nothing
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="jya.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center" class="tdh">
<%
Dim strfirstName
Dim strlastName
Dim strresume
strresume = Request.Form("resume")
strfirstName = Request.Form("firstName")
strlastName = Request.Form("lastName")
Response.Write "<p>Thank you, "
Response.Write "<b>"
Response.Write strfirstName
Response.Write " "
Response.Write strlastName
Response.Write "</b>"
Response.Write ", for your interest in the Agency</p>"
Response.Write "<br>"
Response.Write "<p>Your resume has been submitted.</p>"
Response.Write "<br>"
Response.Write strresume
%>
Per someone's suggestion I have been trying to use FileSystemObject and I have been unsuccessful. Every time I try to test the page on my computer it hangs and says "waiting for localhost".
Here is the script I am using:
<%
Dim objMail, objMailConf
Dim fs, fname
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set fname = Request.Form("resume")
fs.CopyFile fname, "c:\access\"
Set objMail = Server.CreateObject("CDO.Message")
Set objMailConf = Server.CreateObject("CDO.Configuration")
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.enter.net"
objMailConf.fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMailConf.Fields.item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
objMailConf.Fields.Update
Set objMail.Configuration = objMailConf
objMail.From = Request.Form("emailAddress")
objMail.To = "mail@mail.com"
objMail.Subject = Request.Form("emailSubject")
objMail.TextBody = Request.Form("emailText") & vbcrlf & "Home Phone Number: (" & Request.Form("homeArea") & ")" & Request.Form("homeNumber") & vbcrlf & "Cell Phone Number: (" & Request.Form("cellArea") & ")" & Request.Form("cellNumber")
objMail.AttachFile fname
objMail.Fields.Update
objMail.Send
Set objMail = Nothing
Set obMailConf = Nothing
Set fname = Nothing
Set fs = Nothing
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="jya.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div align="center" class="tdh">
<%
Dim strfirstName
Dim strlastName
Dim strresume
strresume = Request.Form("resume")
strfirstName = Request.Form("firstName")
strlastName = Request.Form("lastName")
Response.Write "<p>Thank you, "
Response.Write "<b>"
Response.Write strfirstName
Response.Write " "
Response.Write strlastName
Response.Write "</b>"
Response.Write ", for your interest in the Agency</p>"
Response.Write "<br>"
Response.Write "<p>Your resume has been submitted.</p>"
Response.Write "<br>"
Response.Write strresume
%>