AspEmail Sample Code

AspEmail is an active server component for sending e-mail messages using an external SMTP server in an ASP or VB environment. AspEmail supports multiple recipients, multiple file attachments, HTML format, embedded images and sounds, non-US ASCII character sets, secure mail, and high-performance message queuing.

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

 

<%   
' change to address of your own SMTP server   
strHost = "mail.elinkisp.com"    
If Request("Send") <> "" Then   
   Set Mail = Server.CreateObject("Persits.MailSender")   
  
   ' enter valid SMTP host   
   Mail.Host = strHost    
   Mail.Username = ”user@yourdomain.com" 
   Mail.Password = “password”  
  
    
   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>