Code to send an E-mail utilizing html form ASPEmail component.
<%
mailHost = "mail.yourHost.com" 'Chang this line to yours
dim SendButton, contact, subject, email,message, blankField, strError, strSuccess
email=Request.Form("email")
subject=Request.Form("subject")
message=Request.Form("message")
contact=Request.Form("contact")
if subject="" then
blankField="Provide subject line <br>"
end if
if contact="" then
blankField=blankField&"Provide your name <br>"
end if
if email="" then
blankField=blankField&"Provide email to reply to <br>"
end if
if message="" then
blankField=blankField&"Blank body text!! <br>"
end if
SendButton=Request.Form("Send")="Send"
If SendButton Then
if blankField <> "" then
Response.Write("<font color='red'>" &blankField &" Click the back button to re-try.</font>")
else
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = mailHost
Mail.From = email
Mail.FromName = contact
Mail.AddAddress "yourEmail@yourHost.com" 'Change this line to yours
Mail.Subject = subject
Mail.Body =message
strError= ""
strSuccess = False
On Error Resume Next
Mail.Send
If Err <> 0 Then
strError = Err.Description
else
strSuccess = True
end if
end if
end if
%>
<HTML>
<HEAD><title>Send Email</title></Head>
<BODY >
<table>
<tr>
<td align="center">
<% If strError <> "" Then %>
<h3>Error occurred: <% = strError %></h3>
<% End If %>
<%
If strSuccess =True Then
Response.Write("<font color='red'> Thank you for contacting us. Your e-mail has been sent.</font><br>")
end if
%>
<% if NOT SendButton then %>
<form name="sendMailForm” action="<%=Request.ServerVariables("URL")%>" method="post">
<table border="0" cellpadding="10" cellspacing="1" bgcolor="#999999">
<tr><td>
<b>Name:</b><br />
<input type="text" name="contact" size="20" /><br />
<b>Subject:</b><br />
<input type="text" name="subject" size="20" /><br />
<b>E-mail address:</b><br />
<input type="text" name="email" size="20"><br />
<b>Your message: </b><br />
<textarea name="message" cols="56" rows="15"/></textarea><br><br />
<input type="submit" name="Send" value="Send">
</td></tr></table>
</form>
<% end if %>
</td>
</tr>
</table>
</BODY>