ASP Hosting Top Header
Easy ASP Hosting Logo ASP.NET Hosting
ASP Hosting Contact Information
Windows Hosting
         Home         Hosting         Domains         Support          Order Windows 2003 Hosting
Helm Hosting
 

ASPEmail COM Object Sample

AspEmail is an active server component (COM Object) that enables your ASP application to send email messages via any external SMTP server. The component supports multiple file attachments, multiple recipients, CCs, BCCs, and REPLY-TOs. More information can be found at http://www.aspemail.com

The following is a working sample of how this component works on Active Server hosting accounts. There are literally thousands of other combinations, colors, methods, etc that could be used to accomplish the same function. Please note that we do not provide support for this sample. It is only provided as a guide to help you get started.

All the ASP code is documented. What is not documented is the plain HTML tables which were added for aesthetic purposes.

Please note: When using any ASP Mail COM Objects, you must use the specific internal email IP address assigned to that server and "25" as the port number. We configure SMTP on a non-routable, internal IP with an odd port number so that people can send email through ASP scripts, without having to deal with SMTP authentication issues. You can find out what IP address you should be using by clicking here.

This is what the ASP code looks like:


<%
' Check to see if the "EmailTo" field as filled out, if it was, assume
' all other fields were filled out and try to send email
If Len(Request("EmailTo")) > 0 Then

' Instantiate the COM Object
Set Mail = Server.CreateObject("Persits.MailSender")

' This is the Active Server Internal SMTP Address
Mail.Host = "localhost" (this will change depending on which server your account resides on, click here to find out what IP address is assigned to your server.

' This is the Active Server Internal SMTP Port
Mail.Port = "25"

' This is the FROM email ADDRESS
Mail.From = Request("EmailFrom")

' This is the FROM email NAME
Mail.FromName = Request("EmailFromName")

' This is the Reply To email address
Mail.AddReplyTo Request("ReplyTo")

' This is who the email will be sent to
Mail.AddAddress Request("EmailTo"), Request("EmailToName")

' This is the SUBJECT of the email
Mail.Subject = Request("Subject")

' This is the BODY of the email
Mail.Body = Request("Body")

' This is Error Checking and the "Mail.Send" is the actual action of sending the email
On Error Resume Next
Mail.Send
If Err <> 0 Then
           Response.Write "Error encountered: " & Err.Description
Else
          Response.Write "Mail Sent Successfully."
End If

Else%>

<form name="form1">

           <table>
                      <tr>
                                 <td colspan="2"><b>ASPEmail Sample</b></td>
                      </tr>

                      <tr>
                                 <td valign="top">Email From:</td>
                                 <td><input type="text" name="EmailFrom"></td>
                      </tr>

                      <tr>
                                 <td valign="top">Email From Name:</td>
                                 <td><input type="text" name="EmailFromName"></td>
                      </tr>

                      <tr>
                                 <td valign="top">Reply To:</td>
                                 <td><input type="text" name="ReplyTo"></td>
                      </tr>

                      <tr>
                                 <td valign="top">Email To:</td>
                                 <td><input type="text" name="EmailTo"></td>
                      </tr>

                      <tr>
                                 <td valign="top">Email To Name:</td>
                                 <td><input type="text" name="EmailToName"></td>
                      </tr>

                      <tr>
                                 <td valign="top">Subject:</td>
                                 <td><input type="text" name="Subject"></td>
                      </tr>

                      <tr>
                                 <td valign="top">Body:</td>
                                 <td><textarea cols="40" rows="10" name="Body"></textarea></td>
                      </tr>

                      <tr>
                                 <td></td>
                                 <td><input type="submit" value="Send Email"></td>
                      </tr>
           </table>
</form>

<%End If%>


And this is what it looks like in a web browser:

 

Home |  Hosting |  Resellers |  About Us |  Testimonials |  Site Map |  Contact Us |  Data Center |  Plesk |  Support |  Announcements |  Order