Sending an Email with ASP using ASPEmail Component

The following code sample demonstrates a simple email-sending form using ASPEmail Component available on our Windows Hosting accounts.

<%
' change to address of your domain
strHost = "yourdomain.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>

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

503 valid RCPT command must precede DATA

When sending email, you receive an immediate bounce such as the following: Subject: RE: XXXXXX -...

How do I create an email account?

To create an email account log in to your control panel (http://www.yourdomain.com/cpanel/) and...

How do I use webmail?

You can access your webmail by going to http://www.yourdomain.com/webmail or by going into your...

Is there a mailbox storage limit?

You can define the mailbox storage quota on any mail account via the webmail interface or the...

My e-mail is going to the bulk or spam folder!

We create an SPF record automatically for all domains that are created on our servers and we...