Flare Hosting
Home Products and Services About Us Support Resellers Contact Us Site Map Call Toll-Free: 1-877-97-FLARE (35273)
Support - FAQ
ASP and .NET FAQ - ASP Email Sample ASP script

The following code sample demonstrates a simple email-sending form.

File name: Simple.asp
<%
' change to address of your own SMTP server
strHost = "mail.mydomainname.com"

If Request("Send") <> "" Then
    Set Mail = Server.CreateObject("Persits.MailSender")
    ' enter valid SMTP host
    Mail.Host = strHost

   Mail.From = Request("From") ' From address
    Mail.FromName = Request("FromName") ' optional
    Mail.AddAddress Request("To")

   ' message subject
    Mail.Subject = Request("Subject")
    ' message body
    Mail.Body = Request("Body")
    strErr = ""
    bSuccess = False
    On Error Resume Next ' catch errors
    Mail.Send ' send message
    If Err <> 0 Then ' error occurred
       strErr = Err.Description
    else
       bSuccess = True
    End If
End If
%>

<HTML>
<BODY BGCOLOR="#FFFFFF">
<% If strErr <> "" Then %>
<h3>Error occurred: <% = strErr %>
<% End If %>
<% If bSuccess Then %>
Success! Message sent to <% = Request("To") %>.
<% End If %>
<FORM METHOD="POST" ACTION="Simple.asp">
<TABLE CELLSPACING=0 CELLPADDING=2 BGCOLOR="#E0E0E0">
<TR>
    <TD>Host (change as necessary in script):</TD>
    <TD><B><% = strHost %></B></TD>
</TR>
<TR>
    <TD>From (enter sender's address):</TD>
    <TD><INPUT TYPE="TEXT" NAME="From"></TD>
</TR>
<TR>
    <TD>FromName (optional, enter sender's name):</TD>
    <TD><INPUT TYPE="TEXT" NAME="FromName"></TD>
</TR>
<TR>
    <TD>To: (enter one recipient's address):</TD>
    <TD><INPUT TYPE="TEXT" NAME="To"></TD>
</TR>
<TR>
    <TD>Subject:</TD>
    <TD><INPUT TYPE="TEXT" NAME="Subject"></TD>
</TR>
<TR>
    <TD>Body:</TD>
    <TD><TEXTAREA NAME="Body"></TEXTAREA></TD>
</TR>
<TR>
    <TD COLSPAN=2><INPUT TYPE="SUBMIT" NAME="Send" VALUE="Send Message">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>



See also:

  Domain Search
www.  
  Special Offer
 Free Domain Registration
more info 
 Customer Referral Program
more info 
30day money back guarantee
Microsoft Certified Partners
  Copyright © 1999-2008 Flare Hosting. All Rights Reserved.
  Terms and Conditions of Use  |  Domain Registration Agreement  |  ICANN Policy  |  Guarantees