File: D:/bin/dundas/FreeLibs/AspMail/Samples/AutoResponse.asp
<%@ Language=VBScript %>
<% Option Explicit
Response.Buffer = True 'enable buffering
'*************************************************************************
'Copyright Dundas Software Ltd. 2000. All Rights Reserved.
'
'PURPOSE: Sends an email to the specified recipient with a
' fictitious username and password. A success or
' failure message will be output upon completion of
' the operation.
'
'POST DESTINATION: Self-posting.
'
'INPUT: Email address, first name, last name and optional
' SMTP relay server.
'
'COMMENTS: Uses the QuickSend method to send the email.
' User will be redirected to the Error.asp page if the
' operation is unsuccessful.
'
'Dundas Software Contact Information:
' Email: sales@dundas.com
' Phone: (800) 463-1492
' (416) 467-5100
' Fax: (416) 422-4801
'*************************************************************************
%>
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft FrontPage 4.0">
<title>Dundas Mailer Control Demo: AutoResponse Message</title>
</head>
<body color="black" bgcolor="white">
<table><tr><td><img border="0" height="36" src="images/clouds.jpg"></td></tr></table>
<img align="left" border="0" hspace="5" src="images/headline.gif" width="390" height="50">
<img align="right" border="0" src="images/dundaslogo.gif" hspace="5" WIDTH="160" HEIGHT="18">
<p><p><br><br>
<% If Request("txtEmail") = "" Then
'user has not entered any information yet
%>
<center><img border="0" height="25" src="images/Automaticresponse.gif" width="360"></center>
<p><img align="absMiddle" border="0" height="14" src="images/scenario.gif" width="82"> </p>
<p>Someone has forgotten his/her username and/or password for some sort of web
site account.<br>
The user enters his/her email address and the fictitious account information is
then sent to the specified address.</p>
<p><img border="0" height="14" src="images/features.gif" width="81">
<ul>
<li>Uses the <font color="blue">SMTPRelayServers</font> collection
to specify SMTP servers.
<li>Uses the <font color="blue">QuickSend</font> method to send the email with
one line of code.
<li>Errors are trapped for by using raised exceptions.</li>
</ul>
<form action="AutoResponse.asp" method="post" name="frmAutoResponse">
<table border="0" cellPadding="1" cellSpacing="1" width="40%">
<tr>
<td align="left" size="20%" nowrap><img align="left" border="0" height="16" src="images/Firstname.gif" width="139"></td>
<td align="left" size="80%" nowrap>
<input name="txtFName" id="FName">
</td></tr>
<tr>
<td align="left" size="20%" nowrap><img align="left" border="0" height="16" src="images/Lastname.gif" width="139"></td>
<td align="left" vAlign="top" size="80%" nowrap>
<input name="txtLName" id="LName">
</td>
</tr>
<tr>
<td align="left" size="20%" nowrap><font color="#ffffff">
<img align="left" border="0" height="16" src="images/Email.gif" width="139"></font></td>
<td align="left" size="80%" nowrap>
<input name="txtEmail" id="txtEmail"><font color="red">*</font>
</td>
</tr>
<tr>
<td align="left" size="20%" nowrap>
<img align="left" border="0" height="16" src="images/SMTPRelayserver.gif" width="139"></td>
<td align="left" size="80%" nowrap>
<input name="txtSMTP" id="txtSMTP"> (Optional)
</td>
</tr>
</table><font size="2"><font size="3"><font size="2">
<i>(NOTE: The email is sent directly to the destination server if you do not use an SMTP relay server. Direct send emails are slower than emails sent with relay servers.)</i><br><br>
<input id="send" name="send" type="submit" value="Submit"></font></font></font>
</form>
<% Else
'user has entered required information. Send the email with fictitious
' account information and display a success or failure message.
'enable inline error trapping to trap for any exceptions raised by the Mailer control
On Error Resume Next
Dim objMail 'Mailer object
'create an instance of the control
Set objMail = server.CreateObject("Dundas.Mailer")
'set the smtp server name if the user has specified an SMTP server.
If Request("txtSMTP") <> "" Then
objMail.SMTPRelayServers.Add Request("txtSMTP")
End If
'set the user name and greeting string
Dim userName
If Request("txtFName") <> "" and Request("txtLName") <> "" Then
userName = "Hello " & Request("txtFName") & " " & Request("txtLName") & "."
ElseIf Request("txtFName") = "" and Request("txtLName") <> "" Then
userName = "Hello " & Request("txtLName") & "."
ElseIf Request("txtFName") <> "" and Request("txtLName") = "" Then
userName = "Hello " & Request("txtFName") & "."
Elseif Request("txtFName") = "" and Request("txtLName") = "" Then
userName = "Hello!"
End If
objMail.QuickSend "AnAdministrator@SomeDomainName.com", Request("txtEmail"), "Account information", vbCrLf & userName & vbCrLf & "Your username is UserName." & vbCrLF & "Your password is Password."
If Err.Number <> 0 Then
'see if mail send operation was unsuccessful, if so redirect to error page
Response.Redirect "Error.asp?Error=" & Err.Description
Else
'display success message
Response.Write "<center><br><font face=Arial size=3 color=blue>The previous automatic response was successfully sent."
Response.Write "<p>You can use your browser's Back button to try this again if you wish.</p></font></center>"
End If
'release resources
Set objMail = Nothing
End If
'send contents of html buffer to the browser
Response.End
%>
</body>
</html>