Shortcut Menu

Skip

Main Navigation

Choose your language


ActiveXperts Email Component Add SMTP/POP3 capabilities to any Windows or .NET application

Quicklinks


ActiveXperts Email Component is a software development kit (SDK) that enables the user to send (SMTP) and receive (POP3) e-mail messages. ActiveXperts Email Component 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).


Introduction

This document describes how ActiveXperts Email Component can be integrated into HTML projects. This demo project will ask the user to give an e-mail address and a password on the command prompt, then it will download e-mails from a POP3 server.

Step 1: Installation of ActiveXperts Email Component

When using HTML, there are two ways to install ActiveXperts Email Component on a client PC:

  • Automatically using HTML code;
  • Using the ActiveXperts Email Component InstallShield installation.

Automatic installation using HTML code

You can install the ActiveXperts Email Component automatically using the following HTML code on top of the HTML page:

<object codebase="http://www.activexperts.com/files/smtp-pop3-component/cab/4.0/AxEmail32.cab" 
         classid="CLSID:1A129FBB-C9B4-43F7-8352-30CEF860AD8A" ></object>

The Email Component will be installated automatically. The user will be asked to confirm the installation, because the DLL is coming from an untrusted site (www.activexperts.com). There are two ways to avoid prompting:

  • Add the ActiveX/COM location to the user's trusted sites. You can manage trusted manually (by using the Internet Explorer), through a logon script (by appyling the registry change from the logon script) or by using Active Directory Group Policies;
  • Or use a trusted location for the DLL. For instance your Intranet site, because most probably this site has already been added to the list of trusted sites for all users.

Manual installation using ActiveXperts Email Component installation procedure

On each client PC, download the ActiveXperts Email Component from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create the E-mail objects in HTML

You must use Javascript to declare and create the objects.

Use the following Javascript code to declare and create the 'objPop3' object:

var objPop3 = new ActiveXObject("AxEmail.Pop3");

Step 3: Receive E-mail messages

You can now receive E-mail messages.

The following code will download all messages from the POP3 server:

<!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 Email Component Javascript Demo</title>
  <link rel="Stylesheet" type="text/css" href="css/Layout.css" />
  
  <object codebase="http://www.activexperts.com/files/smtp-pop3-component/cab/4.0/AxEmail32.cab" 
  classid="CLSID:1A129FBB-C9B4-43F7-8352-30CEF860AD8A" ></object>
  <script language="JavaScript" type="text/javascript">
    var objPop3 = new ActiveXObject("AxEmail.Pop3");
    
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    objPop3.LogFile = fso.GetSpecialFolder(2) + "\\AxEmail.Pop3.log";
    // Windows default: 'C:\Users\%USERNAME%\AppData\Local\Temp\AxEmail.Pop3.log'
    
    window.attachEvent("onload", PageLoaded, false);
    
    function PageLoaded() {
      document.getElementById("APIinfo").innerHTML = "Build: " + objPop3.Build + 
                                  "; Module: " + objPop3.Module;
      
      var objForm = document.forms["Pop3SampleForm"]
      objForm.txtLogfile.value = fso.GetSpecialFolder(2) + "\\AxEmail.Pop3.log";
      objForm.txtResult.value = "n/a";
    }
    
    function ListMessages() {
      var objEmailConstants = new ActiveXObject("AxEmail.Constants");
      var objEmail = new ActiveXObject("AxEmail.Message");
      
      objPop3.Authentication = objEmailConstants.POP3_AUTH_AUTO;
      var objForm = document.forms["Pop3SampleForm"];
      
      //Clear all previous results
      for (i = objForm.lvMessages.length - 1; i >= 0; i--) {
        objForm.lvMessages.remove(i);
      }
      
      if (objForm.cbxSecure.checked == 1)
        objPop3.SetSecure(995); // 995 is the default secure POP3 port
      
      if (objPop3.LastError == 0)
      {
        objPop3.Connect(objForm.txtHost.value,objForm.txtAccount.value,objForm.txtPassword.value);
      }
      
      if (objPop3.LastError == 0) 
      {
        var numMessages = objPop3.CountMessages();
      }
        
      if (objPop3.LastError == 0) 
      {
        for (var i = 1; i <= numMessages; i++) {
          objEmail = objPop3.GetEmailHeader(i);
          
          
          if (objPop3.LastError == 0) {
            var NewOption = document.createElement('option');
            NewOption.text = objEmail.Date + ": " + objEmail.FromAddress + 
                              "; Subject" + objEmail.Subject;
            objForm.lvMessages.add(NewOption);
          }
        }
      }

      UpdateResult(objForm);      
      objPop3.Disconnect();
    }
    
    function UpdateResult(objForm) {
      objForm.txtResult.value = objPop3.LastError;
    }
  </script>
</head>
<body>
  <div class="ax_maincontainer">
    <div class="ax_header">
      <div class="ax_stroke"></div>
      <div class="ax_logo"></div>
    </div><!-- /header -->
    <div class="ax_menu">
      | <a href="index.html">Home</a>      
      | <a href="smtp.html">SMTP</a>
      | <a href="pop3.html">POP3</a> |
    </div><!-- /menu -->
    <div class="ax_container">
      <h1>ActiveXperts Email Component Javascript POP3 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.
      </p>
      <form name="Pop3SampleForm" action="pop3.html" method="post">
        <h2>ActiveXperts Email Component:</h2>
        <h3 id="APIinfo"></h3>
        
        <!-- Host, Secure -->
        <label for="Host">Mailserver:</label>
        <p>
          <input type="text" id="Host" name="txtHost" value="pop3.mycompany.com" />
          
          <input type="checkbox" class="ax_cbFix" id="Secure" name="cbxSecure" value="1" />
          <label for="Secure">Secure</label>
        </p>
        
        <!-- Account -->
        <label for="Account">Account:</label>
        <p>
          <input type="text" id="Account" name="txtAccount" value="user@mycompany.com" />
        </p>
        
        <!-- Password -->
        <label for="Password">Password:</label>
        <p>
          <input type="password" id="Password" name="txtPassword" value="" />
        </p>
        
        <!-- Empty row -->
        <div class="ax_clearRow"></div>
        
        <!-- List Messages button -->
        <div class="ax_clearLabel"></div>
        <p>
          <input type="button" name="btnSendMessage" onclick="ListMessages()" 
              value="List Messages" />
        </p>
        
        <!-- Messages Listbox -->
        <label for="Received">Messages received:</label>
        <p>
          <select id="Received" name="lvMessages" class="ax_FullWidth" size="10"></select>
        </p>
        
        <!-- Result -->
        <label for="Result" class="ax_Bold">Result:</label>
        <p>
          <input type="text" id="Result" name="txtResult" class="ax_FullWidth Bold" />
        </p>
        
        <!-- Logfile -->
        <label for="Logfile">Logfile:</label>
        <p>
          <input type="text" id="Logfile" name="txtLogfile" class="ax_FullWidth" />
        </p>
      </form>
      <p>
        This demo uses the ActiveXperts ActiveXperts Email Component, an 
        <a href="http://www.activexperts.com" target="_blank">ActiveXperts Software</a> 
        product.<br />
         <a href="index.html">Back to main page</a>
      </p>
    </div><!-- /container -->
    <div class="ax_footer">
      <div class="ax_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.

NOTE: Demo Projects are created with Microsoft Visual Studio 2008

The ActiveXperts Email Component 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.