Quicklinks
ActiveEmail SMTP/POP3 Toolkit is a software development kit (SDK) that enables the user to send (SMTP) and receive (POP3) e-mail messages. ActiveEmail supports SMTP, POP3, multiple recipients (To, CC, BCC), multiple attachments (ASCII and binary), rich text body formats (RTF/HTML), Unicode, multiple character sets, SMTP authorization (AUTH PLAIN, AUTH LOGIN, AUTH CRAM MD5), POP3 authorization (Plain, APOP), POP3 header download, different character sets (including arabic, chinese, japanese, russian, greek, hebrew and many more), different encodings (including 7/8 bit, quoted-printable, base64).
In this example we are going to create a classic ASP page named 'Default.asp' to send E-mail messages. This demo project will ask the user to give a recipient e-mail address and a message body in the web interface.
Download the ActiveEmail Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
First, create a new directory on the IIS Server's file system. This directory will hold the ASP later on.
From the 'Start menu', click on 'Administrative Tools' and click on 'Internet Information Services (IIS) Manager'. Right-click on the 'Web Sites' container and choose 'New->Web Site':
The 'Web Site Creation Wizard' is shown, guiding you thorugh the process of creating a new web site. Provide all necessary information:
You're now able to write an ASP script to send e-mail using ActiveEmail Toolkit.
Create a new ASP script called DEFAULT.ASP in the directory that was created in Step2, using your favorite editor. On top of the ASP code, insert the following lines to declare and create the Smtp object:
<object runat="server" progid="ActiveEmail.Smtp" id="objSmtp"></object> <object runat="server" progid="ActiveEmail.EmailMessage" id="objEmail"></object> <object runat="server" progid="ActiveEmail.EmailConstants" id="objConstants"></object>
Now, test if your new web site is working well with the ActiveEmail Toolkit using your browser. If you are using Microsoft Internet Explorer, it is recommended to disable friendly error message because this default setting doesn't show any ASP error message, making it hard to debug if there are any problems:
Now, use the following piece of code in your DEFAULT.ASP page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ActiveXperts ActiveEmail Toolkit ASP Demo</title>
<object runat="server" progid="ActiveEmail.Smtp" id="objSmtp"></object>
<object runat="server" progid="ActiveEmail.EmailMessage" id="objEmail"></object>
<object runat="server" progid="ActiveEmail.EmailConstants" id="objConstants"></object>
<title>ActiveEmail Toolkit Demo</title>
</head>
<body>
ActiveEmail Toolkit version: <% = objSmtp.Version %><br>
ActiveEmail Toolkit expiration date: <% = objSmtp.ExpirationDate %>
</body>
</html>
And test it with your favorite browser.
You can now send e-mail messages.
The following ASP code shows how to send an e-mail message:
If (objEmail.LastError = 0 AND objSmtp.LastError = 0) Then objSmtp.Send(objEmail) End If
Following you can find the full source code which is also included in the ActiveEmail Toolkit package.
<object runat="server" progid="ActiveEmail.Smtp" id="objSmtp"></object>
<object runat="server" progid="ActiveEmail.EmailMessage" id="objEmail"></object>
<object runat="server" progid="ActiveEmail.EmailConstants" id="objConstants"></object>
<%
strResult = "n/a"
Set fso = CreateObject("Scripting.FileSystemObject")
strLogfile = fso.GetSpecialFolder(2) & "\ActiveXperts.Smtp.log"
objSmtp.LogFile = strLogfile
' Windows default: "C:\Windows\Temp\ActiveXperts.Smtp.log"
If(Request("btnSendMessage") <> "") Then
objEmail.FromName = Request("txtFromName")
objEmail.FromAddress = Request("txtFromAddress")
If (Request("txtToAddress") <> "") Then
objEmail.AddTo Request("txtToAddress"), Request("txtToAddress")
End If
If (objEmail.LastError = 0 AND Request("txtCcAddress") <> "") Then
objEmail.AddCC Request("txtCcAddress"), Request("txtCcAddress")
End If
If (objEmail.LastError = 0 AND Request("txtBccAddress") <> "") Then
objEmail.AddBcc Request("txtBccAddress"), Request("txtBccAddress")
End If
If (objEmail.LastError = 0) Then
objEmail.Subject = Request("txtSubject")
objEmail.Encoding = Request("ddlEncoding")
Select Case Request("ddlPriority")
case "Highest Priority"
objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_HIGHEST
case "High Priority"
objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_HIGH
case "Normal Priority"
objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_MEDIUM
case "Low Priority"
objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_LOW
case "Lowest Priority"
objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_LOWEST
End Select
objEmail.BodyPlainText = Request("txtPlainBody")
objEmail.BodyHtml = Request("txtHtmlBody")
End If
If (objEmail.LastError = 0) Then
objSmtp.Connect Request("txtHost"), Request("txtAccount"), Request("txtPassword")
End If
If (objEmail.LastError = 0 AND objSmtp.LastError = 0) Then
objSmtp.Send(objEmail)
End If
If (objEmail.LastError <> 0) Then
strResult = objEmail.lastError & ": " & objEmail.GetErrorDescription(objEmail.LastError)
Else
strResult = objSmtp.lastError & ": " & objSmtp.GetErrorDescription(objSmtp.LastError)
End If
objSmtp.Disconnect()
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ActiveXperts ActiveEmail Toolkit Demo</title>
<link rel="Stylesheet" type="text/css" href="css/Layout.css" />
</head>
<body>
<div class="maincontainer">
<div class="header">
<div class="stroke"></div>
<div class="logo"></div>
</div><!-- /header -->
<div class="container">
<h1>ActiveXperts ActiveEmail Toolkit ASP SMTP Sample</h1>
<hr />
<p>
Simple Mail Transfer Protocol (SMTP) is an Internet standard for electronic mail (e-mail)
transmission across Internet Protocol (IP) networks.
SMTP is specified for outgoing mail transport and uses TCP port 25 by default.<br />
<br />
<b>
SSL/TLS Encryption does not work in ASP since the default ASP user has no
user certificate store.
</b>
</p>
<form action="smtp.asp" method="post">
<h2>ActiveEmail Toolkit:</h2>
<h3>Build: <% = objSmtp.Build %>; Module: <% = objSmtp.Module %></h3>
<!-- Server, Secure -->
<label for="Server">Mailserver:</label>
<p>
<input type="text" id="Server" name="txtHost" value="smtp.mycompany.com" />
</p>
<!-- Account -->
<label for="Account">Account:</label>
<p>
<input type="text" id="Account" name="txtAccount" />
*SSL/TLS Encryption does not work in ASP
</p>
<!-- Account Text -->
<div class="clearLabel"></div>
<p style="margin-left: 576px; margin-Top:-5px;">
since the default ASP user has no user certificate store.
</p>
<!-- Password -->
<label for="Password">Password:</label>
<p>
<input type="password" id="Password" name="txtPassword" />
</p>
<!-- Empty row -->
<div class="clearRow"></div>
<!-- Sender Name -->
<label for="Sender">Sender name:</label>
<p>
<input type="text" id="Sender" name="txtFromName" />
</p>
<!-- Sender Email -->
<label for="Sender">Sender e-mail:</label>
<p>
<input type="text" id="Sender" name="txtFromAddress" />
</p>
<!-- Empty row -->
<div class="clearRow"></div>
<!-- To -->
<label for="To">To:</label>
<p>
<input type="text" id="To" name="txtToAddress" value="john@mycompany.com" />
</p>
<!-- Cc -->
<label for="Cc">Cc:</label>
<p>
<input type="text" id="Cc" name="txtCcAddress" />
</p>
<!-- Bcc -->
<label for="Bcc">Bcc:</label>
<p>
<input type="text" id="Bcc" name="txtBccAddress" />
</p>
<!-- Empty row -->
<div class="clearRow"></div>
<!-- Subject -->
<label for="Subject">Subject:</label>
<p>
<input type="text" id="Subject" name="txtSubject" />
</p>
<!-- PlainBody -->
<label for="PlainBody">Body:</label>
<p>
<textarea id="PlainBody" name="txtPlainBody" style="height: 60px;"></textarea>
</p>
<!-- HtmlBody -->
<label for="HtmlBody">Body HTML (optional):</label>
<p>
<textarea id="HtmlBody" name="txtHtmlBody" style="height: 60px;"></textarea>
</p>
<!-- Empty row -->
<div class="clearRow"></div>
<!-- Char. Set -->
<label for="CharSet">Char. Set:</label>
<p>
<select name="ddlEncoding">
<option value="0">Standard</option>
<option value="65001">UTF8</option>
</select>
</p>
<!-- Priority -->
<label for="Priority">Priority:</label>
<p>
<select name="ddlPriority">
<option>Highest Priority</option>
<option>High Priority</option>
<option selected="true">Normal Priority</option>
<option>Low Priority</option>
<option>Lowest Priority</option>
</select>
</p>
<!-- SendButton -->
<div class="clearLabel"></div>
<p>
<input type="submit" name="btnSendMessage" value="Send Message" />
</p>
<!-- Empty row -->
<div class="clearRow"></div>
<!-- Result -->
<label for="Result"class="Bold">Result:</label>
<p>
<input type="text" id="Result" class="FullWidth Bold" name="txtResult"
value="<% = strResult %>" />
</p>
<!-- Logfile -->
<label for="Logfile">Logfile:</label>
<p>
<input type="text" id="LogFile" name="txtLogFile" class="FullWidth"
value="<% = strLogfile %>" />
</p>
</form>
<p>
This demo uses the ActiveXperts ActiveEmail Toolkit, an
<a href="http://www.activexperts.com" target="_blank">ActiveXperts Software</a>
product.<br />
<a href="Default.asp">Back to main page</a>
</p>
</div><!-- /container -->
<div class="footer">
<div class="icon"></div>
<p>
© 2011 <a href="http://activexperts.com" target="_blank">
Active<font color="#CCC000000">X</font>perts Software B.V.</a>
All rights reserved.
<small>
<a href="http://activexperts.com/activexperts/contact" target="_blank">Contact Us</a> |
<a href="http://activexperts.com/activexperts/termsofuse" target="_blank">Terms of Use</a> |
<a href="http://activexperts.com/activexperts/privacypolicy" target="_blank">Privacy Policy</a>
</small>
</p>
</div><!-- /footer -->
</div><!-- /maincontainer -->
</body>
</html>
You can download the full source code of this project from the ActiveXperts FTP site: ftp://ftp.activexperts-labs.com/samples/smtp-pop3-component/. There are many other working samples included with the product or on the FTP site.
The ActiveEmail Toolkit project ships with a set of Microsoft Visual Studio .NET samples. The projects are created with Microsoft Visual Studio 2008.
Users with a later version of Microsoft Visual Studio can open such a project. The Visual Studio Conversion Wizard will guide you through the process of converting the project to the version used.