http://www.chrispearson.org/pages/programming/vbscript/Email/processmail_code.asp
09h15
Friday, 21. November 2008

SEND EMAIL

This is the HTML and ASP code that sends the email - Note that it displays the passed parameters which it wouldn't do in a production environment. HTML is shown in black and VBScript is purple (or pink, depending on your eyesight.)

It might be useful to include the informative feedback in a real-world ASP page to allow testing then to comment-out the writes to the browser once the page is working.

ASP Email - main article

 

This is the code for the entire ASP web page:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<head>
<title>Process output from HTML form and send an email</title>
</head>
<body>
<FONT COLOR="#000000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">This
shows the parameters passed for the current email message:<BR>
<BR>
</FONT>
<TABLE WIDTH="80%" BORDER="0" CELLPADDING="4" CELLSPACING="0" BGCOLOR="#CCCCCC">
<TR>
<TD WIDTH="34%"><FONT COLOR="#000000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">email
from</FONT></TD>
<TD WIDTH="66%"> <FONT COLOR="#000000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">
<% =request("txtFrom") %>
</FONT></TD>
</TR>
<TR>
<TD><FONT COLOR="#000000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">email
to</FONT></TD>
<TD><FONT SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">
<% =request("txtTo") %>
</FONT></TD>
</TR>
<TR>
<TD><FONT COLOR="#000000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">subject</FONT></TD>
<TD><FONT SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">
<% =request("txtSubject") %></FONT></TD>
</TR>
<TR>
<TD><FONT COLOR="#000000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">body</FONT></TD>
<TD><FONT SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">
<% =request("txtBody") %></FONT></TD>
</TR>
</TABLE>
<%
'
' This sends the email message
'

Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.To = Request("txtTo")
objNewMail.From = Request("txtFrom")
objNewMail.Subject = Request("txtSubject")
objNewMail.Body = Request("txtBody")
objNewMail.BodyFormat = 1
objNewMail.MailFormat = 1
objNewMail.Send
Set objNewMail = Nothing

%>
<P><FONT COLOR="#FF0000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif"><STRONG>Email
sent to <% =Request("txtTo") %></STRONG></FONT></P>
<P><FONT COLOR="#000000" SIZE="2" FACE="Verdana, Arial, Helvetica, sans-serif">
<A HREF="sendmail.asp">Return to sendmail.asp page</A>
</FONT></P>
</body>
</html>

 

ASP Email - main article

 

xxx,xxx

copyright ©2000 - 2008 Chris Pearson