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 receive E-mail messages through the POP3 protocol. This demo project will ask the user for the username and password of the POP3 server where the messages are located.
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 receive 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.
<object runat="server" progid="ActiveEmail.Pop3" id="objPop3"></object> <object runat="server" progid="ActiveEmail.EmailMessage" id="objEmail"></object> <object runat="server" progid="ActiveEmail.EmailConstants" id="objEmailConstants"></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:
In this code we will create an 'objPop3' object which is responsible for storing the POP3 information. The 'objEmail' object will contain all the information regarding the e-mail message itself. The 'objEmailConstants' containes information which ir relative to some costant values of the objEmail itself.
Now, use the following piece of code in your DEFAULT.ASP page:
<object runat="server" progid="ActiveEmail.Pop3" id="objPop3"></object>
<object runat="server" progid="ActiveEmail.EmailMessage" id="objEmail"></object>
<object runat="server" progid="ActiveEmail.EmailConstants" id="objEmailConstants"></object>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>ActiveXperts Mobile Messaging Toolkit Demo</title>
<link rel="Stylesheet" type="text/css" href="css/Layout.css" />
</head>
<body>
<div class="maincontainer">
<div class="container">
<h1>Mobile Messaging Toolkit ASP POP3 Sample</h1>
<hr />
<form action="pop3.asp" method="post">
<h2>Mobile Messaging Toolkit:</h2>
<h3>Build: <% = objPop3.Build %>; Module: <% = objPop3.Module %></h3>
</div><!-- /container -->
</div><!-- /maincontainer -->
</body>
</html>
Test this code with your favorite browser.
The following code will get all the e-mails from the POP3 server and create an array list of messages. This code will only be executed if there was no error while establing the connection.
You can now receive E-mail messages.
If (objPop3.LastError = 0) Then
For i=1 to numMessages
Set ReceivedMail = objPop3.GetEmailheader(i)
strResult = objPop3.LastError & ": " & objPop3.GetErrorDescription(objPop3.LastError)
If (objPop3.LastError = 0) Then
Set arrMessages(i - 1) = ReceivedMail
End If
Next
End If
Following you can find the full source code which is also included in the ActiveEmail Toolkit package.
<object runat="server" progid="ActiveEmail.Pop3" id="objPop3"></object>
<object runat="server" progid="ActiveEmail.EmailMessage" id="objEmail"></object>
<object runat="server" progid="ActiveEmail.EmailConstants" id="objEmailConstants"></object>
<%
Dim arrMessages()
strResult = "n/a"
Set fso = CreateObject("Scripting.FileSystemObject")
strLogfile = fso.GetSpecialFolder(2) & "\ActiveXperts.Pop3.log"
objPop3.LogFile = strLogfile
' Windows default: "C:\Windows\Temp\ActiveXperts.Pop3.log"
If(Request("btnSendMessage") <> "") Then
objPop3.Authentication = objEmailConstants.POP3_AUTH_AUTO
If (objPop3.LastError = 0) Then
objPop3.Connect Request("txtHost"), Request("txtAccount"), Request("txtPassword")
strResult = objPop3.LastError & ": " & objPop3.GetErrorDescription(objPop3.LastError)
End If
If (objPop3.LastError = 0) Then
numMessages = objPop3.CountMessages()
strResult = objPop3.LastError & ": " & objPop3.GetErrorDescription(objPop3.LastError)
Dim ReceivedMail
Redim arrMessages(numMessages - 1)
If (objPop3.LastError = 0) Then
For i=1 to numMessages
Set ReceivedMail = objPop3.GetEmailheader(i)
strResult = objPop3.LastError & ": " & objPop3.GetErrorDescription(objPop3.LastError)
If (objPop3.LastError = 0) Then
Set arrMessages(i - 1) = ReceivedMail
End If
Next
End If
End If
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 POP3 Sample</h1>
<hr />
<p>
In computing, the Post Office Protocol (POP) is an application-layer Internet standard
protocol used by local e-mail clients to retrieve e-mail from a remote server over a
TCP/IP connection and uses TCP port 110 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="pop3.asp" method="post">
<h2>ActiveEmail Toolkit:</h2>
<h3>Build: <% = objPop3.Build %>; Module: <% = objPop3.Module %></h3>
<!-- Host, Secure -->
<label for="Host">Mailserver:</label>
<p>
<input type="text" id="Host" name="txtHost" value="pop3.mycompany.com" />
</p>
<!-- Account -->
<label for="Account">Account:</label>
<p>
<input type="text" id="Account" name="txtAccount" value="user@mycompany.com" />
*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" value="" />
</p>
<!-- Empty row -->
<div class="clearRow"></div>
<!-- List Messages button -->
<div class="clearLabel"></div>
<p>
<input type="submit" name="btnSendMessage" value="List Messages" />
</p>
<!-- Messages Listbox -->
<label for="Received">Messages received:</label>
<p>
<select id="Received" name="lvMessages" class="FullWidth" size="10">
<%
For each Mail in arrMessages
Response.Write("<option>" & Mail.Date & ": " & Mail.FromAddress & _
"; Subject: " & Mail.Subject & "</Message>")
Next
%>
</select>
</p>
<!-- Result -->
<label for="Result" class="Bold">Result:</label>
<p>
<input type="text" id="Result" name="txtResult" class="FullWidth Bold"
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.