I have hacked together an ASP script to email my Online form responses to me. The form works when I use a mailto: in the form action but I would like to use a CDOSYS script instead. Below is the script I am calling from my form action. I think it is close but I am a complete newbie to ASP. Your suggestions would be appreciated.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'First lets Dim all the variables we need
Dim MyMail
Dim MyBody
Dim MyEmail
Dim MyFirstname
Dim MyLastname
Dim MyMiddleinitial
Dim MySex
Dim MyAreastudies
Dim MyDatesubmitted
Dim MyLocaladdress
Dim MyCity
Dim MyState
Dim MyPermaddress
Dim MyPermcity
Dim MyPermstate
Dim MySex
Dim MyPhonenumber
Dim MyCSUID
Dim MyAcademicadvisor
Dim MyASadvisor
Dim MyMajor
Dim MyDepartment
Dim MyCurrentterm
Dim MyYearofGraduation
Dim MyAcademicyear
Dim MyComment
'Now lets get some values for the variables from the form
MyEmail = Request.Form("Email")
MyFirstname = Request.Form("FirstName")
MyLastname = Request.Form("LastName")
Mymiddleinitial = Request.Form("MI")
MySex = Request.Form("sexselect")
MyDatesubmitted = Request.Form("DateSubmitte
d")
MyAreastudies = Request.Form("AsianStudies
")
MyLocaladdress = Request.Form("LocalAddress
")
MyCity = Request.Form("City")
MyState = Request.Form("State")
MyPermaddress = Request.Form("PermAddress"
)
MyPermcity = Request.Form("PermCity")
MyPermstate = Request.Form("PermState")
MyPhonenumber = Request.Form("PhoneNumber"
)
MyCSUID = Request.Form("CSUID")
MyAcademicadvisor = Request.Form("AcademicAdvi
sor")
MyASadvisor = Request.Form("ASAdvisor")
MyMajor = Request.Form("Major")
MyDepartment = Request.Form("Department")
MyCurrentterm = Request.Form("CurrentTerm"
)
MyYearofGraduation = Request.Form("YearofGradua
tion")
MyAcademicyear = Request.Form("AcademicYear
")
MyComment = Request.Form("Comment")
'Now lets build the body of the email from the data in the form
MyBody = "First Name: "& MyFirstname & vbcrlf
MyBody = MyBody & "Last Name: "& MyLastname & vbcrlf
MyBody = MyBody & "Middle Initial: "& Mymiddleinitial & vbcrlf
MyBody = MyBody & "Email: "& MyEmail & vbcrlf
MyBody = MyBody & "Sex: "& MySex & vbcrlf & vbcrlf
MyBody = MyBody & "Date Submitted: "& MyDatesubmitted & vbcrlf
MyBody = MyBody & "Area Study: "& MyAreastudies & vbcrlf
MyBody = MyBody & "Local Address: "& MyLocaladdress & vbcrlf
MyBody = MyBody & "City: "& MyCity & vbcrlf
MyBody = MyBody & "State: "& MyState & vbcrlf
MyBody = MyBody & "Perm Address: "& MyPermaddress & vbcrlf
MyBody = MyBody & "Perm City: "& MyPermcity & vbcrlf
MyBody = MyBody & "Perm State: "& MyPermstate & vbcrlf
MyBody = MyBody & "Phone Number: "& MyPhonenumber & vbcrlf
MyBody = MyBody & "CSUID: "& MyCSUID & vbcrlf
MyBody = MyBody & "Academic Advisor: "& MyAcademicadvisor & vbcrlf
MyBody = MyBody & "Area Studies Advisor: "& MyASadvisor & vbcrlf
MyBody = MyBody & "Major: "& MyMajor & vbcrlf
MyBody = MyBody & "Current Term: "& MyCurrentterm & vbcrlf
MyBody = MyBody & "Department: "& MyDepartment & vbcrlf
MyBody = MyBody & "Year of Graduation: "& MyYearofGraduation & vbcrlf
MyBody = MyBody & "Academic Year: "& MyAcademicyear & vbcrlf
MyBody = MyBody & "Comment: "& MyComment & vbcrlf & vbcrlf
MyBody = MyBody & MyComment
'Now lets put the variables and other information we need into the mailing script
Set MyMail = CreateObject("CDO.Message"
)
MyMail.From = MyEmail
MyMail.To = "myemail@blabla.edu"
MyMail.Subject = "Test message using CDOSYS"
MyMail.TextBody = MyBody
MyMail.Send
Set MyMail= nothing
Response.Write("Your e-mail has been sent")
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml"
>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
</body>
</html>