CDO (CDONTS)
Collaboration Data Objects (CDO) allows you to collect information
in an html form and send that information via email. You can use
CDO on the server www4 and oak. Note: Pine requires a newer
version of CDO. Click here for more
information.
First, an HTML form is created, posting either to the same page
or a confirmation page that will display a message and send the
email. The sample code below shows the code that actually creates
and sends the email based on the form fields:
<%
'declare variables for the mail object (oMail) and the email body (strEmailBody)
Dim oMail, strEmailBody
'Create the CDO object
Set oMail = Server.CreateObject("CDONTS.NewMail")
'places body of the email into the variable strEmailBody, formatted using 'HTML
strEmailBody = "<html><head><h3>CDONTS Example</h3></head>" _
&"<body>This request was submitted at " & Time & " on " & Date
_
&"<p>From: " & Request.Form("name") & "</p><p>Email: " _
&Request.Form("email") & "</p><p>Comments: " & Request.Form("Comments")
_
&"</body></html>"
'creates the email using the oMail object and the string strEmailBody
oMail.To = "your.name@nau.edu"
oMail.From = "Whatever@nau.edu"
'oMail.Bcc = " "
'oMail.Cc = " "
oMail.Subject = "CDONTS example"
oMail.BodyFormat = 0
oMail.MailFormat = 0
oMail.Body = strEmailBody
oMail.Send
'Resets the oMail object to Nothing
Set oMail = Nothing
%>
For more information on CDO, visit Microsoft's
how-to article number Q186204.
Back to the Web Developer's Hub |