Normally I would use PHP or PERL to perform the task of creating and sending e-mail from a HTML form, but unfortunately not all web-host providers have this functionality. Some platforms are offered as Windows servers (*shudder*) and hence only have support for ASP. So, occurring far too often in this industry, I had to learn another new language to perform the simple task I was assigned.
<%
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")
' declare variables
Dim EmailFrom
Dim EmailTo
Dim Subject
Dim Name
Dim Email
Dim Phone
Dim Details
' get posted data into variables
EmailFrom = "info@xxx.xxx.xx"
EmailTo = "info@xxx.xxx.xx"
Subject = "Inquiry"
Name = Trim(Request.Form("Name"))
Email = Trim(Request.Form("Email"))
Phone = Trim(Request.Form("Phone"))
Details = Trim(Request.Form("Details"))
' prepare email body text
Dim Body
Body = Body & "Name: " & Name & VbCrLf
Body = Body & "Email: " & Email & VbCrLf
Body = Body & "Phone: " & Phone & VbCrLf
Body = Body & "Details: " & Details & VbCrLf
' This code assumes the above CDO
'instantiation code is included
objCDO.To = EmailTo
objCDO.From = EmailFrom
objCDO.Subject = Subject
objCDO.Body = Body
objCDO.Send
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Mail Form</title>
</head>
<body>
<table width="660">
<tr>
<td >
<p>
Thank you for enquiring! We will get back to you within 1 working day.
</p>
</td>
</tr>
</table>
<br />
</body>
</html>
No comments:
Post a Comment
Thanks for contributing!! Try to keep on topic and please avoid flame wars!!