ActiveXperts Email Component Manual

© ActiveXperts Software B.V.  contact@activexperts.com

1. Introduction

1.1. Introduction

ActiveXperts Email Component provides an easy-to-use interface to SMTP and POP3 email communications. It's perfectly suited for situations in which emails have to be sent/received automatically, or in batches, from within applications, webservers, or from the command-line. It has proven its strength in many business environments over the years.

ActiveXperts Email Component features the following:

  • Send messages using SMTP;
  • Receive messages using POP3;
  • Embedded objects in message body, like sounds, images, etc.;
  • Connect to secure server using TLS / SSL
  • SMTP authorization, supporting AUTH PLAIN, AUTH LOGIN and AUTH CRAM-MD5 login algorithms;
  • POP3 authorization, supporting Plain text and APOP3 authorization;
  • Load and save MIME files;
  • Detailed error descriptions;
  • Advanced protocol log options;
  • And more.

ActiveXperts Email Component includes samples for many development tools, including:

  • Visual Basic .NET - Windows .NET based application;
  • Visual C# .NET - Windows .NET based applications;
  • Visual Basic 6 - Windows based applications;
  • ASP .NET - Web site based on Active Server Pages and the .NET Framework;
  • ASP Classic - Web site based on Active Server Pages (server-side scripting);
  • PHP - Embedded HTML scripting;
  • VBScript - Windows based scripts;
  • Java/Javascript - Java based scripts;
  • HTML - Client scripts within HTML pages;
  • Any other development platform that supports ActiveX/COM components.

1.2. Architecture

ActiveXperts Email Component is built on top of the Microsoft WinSock drivers. It does NOT replace any Windows drivers during installation; it neither adds any files or components to the Windows or Windows System directory.

The core of ActiveXperts Email Component is an ActiveX/COM component that comes in a 32-bit and a 64-bit version:

  • AxEmail32.dll - the 'ActiveXperts Email Component' for 32-bit platforms;
  • AxEmail64.dll - the 'ActiveXperts Email Component' for 64-bit platforms;

ActiveXperts Email Component can be distributed easily to many PC's. Once you have purchased the licenses, you copy the AxEmail32.dll or AxEmail64.dll to the PCs and register the DLL on that PC.

2. System requirements

2.1. System requirements

ActiveXperts Email Component Toolkit can be used by any of the following operating systems:

  • Windows Server 2012 (64-bit)
  • Windows Server 2008R2 (64-bit)
  • Windows Server 2008 (32-bit and 64-bit)
  • Windows Server 2003 (32-bit and 64-bit)
  • Windows 8 (32-bit and 64-bit)
  • Windows 7 (32-bit and 64-bit)
  • Windows Vista (32-bit and 64-bit)
  • Windows XP (32-bit and 64-bit)

NOTE: On 64 bits systems, you can run 32- and 64 bit programs. To integrate ActiveXperts Email Component in a 64-bit (web) application of service, use the 64-bit AxEmail64.dll. To integrate ActiveXperts Email Component in a 32-bit (web) application of service, use the 32-bit AxEmail32.dll.

2.2. Supported platforms

The ActiveXperts Email Component Toolkit can be used by any of the following programming languages:

  • Visual Basic .NET
  • Visual C# .NET
  • Visual Basic 6
  • Visual C++
  • Delphi 6.x or higher
  • ASP .NET
  • ASP 2.x
  • PHP
  • ColdFusion
  • VBScript
  • Java/Javascript
  • HTML
  • Any other development platform that supports ActiveX/COM components

3. Installation

3.1. Introduction

The ActiveXperts Email Component package consists of 3 modules; any combination of components can be installed:

  • The ActiveXperts Email Component COM components - core components 'AxEmail32.dll' (to embed in 32-bit applications) and 'AxEmail64.dll' (to embed in 64-bit applications);
  • The ActiveXperts Email Component Help Files - documentation;
  • The ActiveXperts Email Component Sample Files - samples for various development platforms.

3.2. Installation (Automatic)

To automatically install ActiveXperts Email Component, download AxEmailSetup.exe and start the installation. The InstallShield wizard will guide you through the rest of the setup.

On 32-bit operating systems, it will automatically register the 32-bit ActiveX DLL 'AxEmail32.dll', to support 32-bit applications.

On 64-bit operating systems, it will automatically register the 64-bit ActiveX DLL 'AxEmail64.dll', to support 64-bit applications; it will also automatically register the 32-bit ActiveX DLL 'AxEmail32.dll', to support 32-bit applications.

3.3. Installation (Manual)

To manually install the ActiveXperts Email Component core files, perform the following actions:

  • Perform one installation of ActiveXperts Email Component on an available computer, to extract the 'AxEmail32.dll' and 'AxEmail64.dll' core ActiveX files
  • To embed ActiveXperts Email Component in 64-bit applications, copy the 'AxEmail64.dll' ActiveX file to the destination computer hard drive, and register the DLL by running the following command from the command-line on the destination computer:
    REGSVR32 <dest-location>\AxEmail64.dll
  • To embed ActiveXperts Email Component in 32-bit applications, copy the 'AxEmail32.dll' ActiveX file to the destination computer hard drive, and register the DLL by running the following command from the command-line on the destination computer:
    REGSVR32 <dest-location>\AxEmail32.dll

4. How to use

4.1. Introduction

The ActiveXperts Email Component is an ActiveX component. ActiveX is a Microsoft framework for defining reusable software components in a programming language-independent way. This is why it's possible to use the Email Components in most programming and scripting languages available for Windows.

One of the most important aspects to using the Email Component may be creating an instance in the programming language of choice. Once a reference to the ActiveX component has been made and it's objects have been instantiated the use of this component should be very straightforward.

In this section a couple of programming environments are highlighted and their way to access the objects in the Email Component is demonstrated.

4.2. Visual Basic .NET

Add a reference to the Email Component object using the Visual Basic Solution Explorer:

  • Start the Solution Explorer view, go to the project's 'References' container
  • Choose 'Add Reference' from the context menu
  • Select the COM tab, choose the 'ActiveXperts Email Component' component

The following code shows how to declare, create and use one of the Email Component objects:

Imports AxEmail

...

Dim objSmtp As AxEmail.Smtp                                ' Declaration
objSmtp = New AxEmail.Smtp()                               ' Creation

' Display version information
Console.WriteLine("ActiveXperts Email Component {0}" & vbLf, objSmtp.Version)

4.3. Visual C# .NET

Add a reference to the Email Component object using the Visual C# Solution Explorer:

  • Start the Solution Explorer view, go to the project's 'References' container
  • Choose 'Add Reference' from the context menu
  • Select the COM tab, choose the 'ActiveXperts Email Component' component

The following code shows how to declare, create and use one of the Email Component objects:

using AxEmail;

...
    
AxEmail.Smtp objSmtp;                                      // Declaration
objSmtp = new AxEmail.Smtp();                              // Creation

// Display version information
Console.WriteLine("ActiveXperts Email Component {0}\n", objSmtp.Version);

4.4. Visual Basic

The Email Component can be used in Visual Basic 6.x or higher. In Visual Basic, go to the 'Project/References...' menu item and check the box next to Email Component Type Library. Now, you can declare and create Email Component objects.

The following code shows how to declare, create and use one of the Email Component objects:

Dim objSmtp As AxEmail.Smtp                                ' Declaration
Set objSmtp = New AxEmail.Smtp                             ' Creation

' Display version information
Me.Caption = "ActiveXperts Email Component " & objSmtp.Version

4.5. Visual C++

ActiveXperts Email Component can be used in Visual C++ projects. To do so:

  • Import: AxEmail.tlb
  • Include: AxEmailConstants.h

The following code shows how to declare, create and use one of the Email Component objects:

#import "AxEmail.tlb"
#include "AxEmailConstants.h"

...

CoInitialize(NULL);                                        // Initialize COM

AxEmail::ISmtpPtr oSmtp = NULL;                            // Declaration
oSmtp.CreateInstance(__uuidof(AxEmail::Smtp));             // Creation

' Display version information
_tprintf(_T("ActiveXperts Email Component %s\n"), (LPCTSTR)oSmtp->Version);

oSmtp.Release();

CoUninitialize();

4.6. ASP Classic

To use the Email Component objects in ASP classic make sure the component has been installed on the server.

The following code shows how to declare, create and use one of the Email Component objects:

<html>
  <body>
    Version:
    <script language="vbscript" runat="server">
   
      Set objSmtp = CreateObject("AxEmail.Smtp")           ' Declaration and Creation

      ' Display version information
      Response.Write "ActiveXperts Email Component " & objSmpp.Version

    </script>
  </body>
</html>

4.7. HTML/Javascript

On top of your HTML/Javascript code, refer to the ActiveXperts Email Component in the following way:

<object codebase="http://activexperts.com/files/smtp-pop3-component/cab/4.1/axemail32.cab" 
        classid="CLSID:3BCF1B58-7071-4564-9D1D-FA008B19179A" ></object>

The following code shows how to declare, create and use one of the Email Component objects:

<script language="JavaScript" type="text/javascript">

  var objSmtp = new ActiveXObject("AxEmail.Smtp")          ' Declaration and Creation
  
  ' Display version information
  document.write("<h1>ActiveXperts Email Component " + objSmtp.Version + "</h1>");

</script>

4.8. Delphi 7.x or higher

First, add a reference to the Email Component objects:

  • Go to Project->Import Type Library
  • Select 'ActiveXperts Email Component Type Library'
  • Click 'Install'
  • The project 'dclusr.dpk' will be opened. Click 'Yes'

The following code shows how to declare, create and use one of the Email Component objects:

program Project1;

{$APPTYPE CONSOLE}

' Use ActiveX, Windows and AXEmail_TLB
uses
  SysUtils, ActiveX, Windows,
  AXEMAIL_TLB;

var
 objSmtp: Smtp;                                          ' Declaration

begin
  CoInitialize(nil);                                     ' Initialize COM

  objSmtp := CoSmtp.Create;                              ' Creation

  ' Display version information
  Writeln('ActiveXperts Email Component ' + objSmtp.Version);

  CoUninitialize
end.

5. Smtp

5.1. Introduction

The Smtp object implements the SMTP (Simple Mail Transfer Protocol). The SMTP protocol is the de facto standard protocol for sending email through on the internet.

This object can be used to connect to a remote SMTP server and send out one or more email messages.

Send email through SMTP

Send an email through the SMTP protocol

Set objSmtp = CreateObject("AxEmail.Smtp")              ' Create the SMTP Protocol object
Set objMail = CreateObject("AxEmail.Message")           ' Create the email message object

Wscript.Echo "ActiveXperts Email Component Version " & objSmtp.Version & "; Build " & _
  objSmtp.Build & "; Module " & objSmtp.Module
WScript.Echo "License Status: " & objSmtp.LicenseStatus & vbCrLf

objSmtp.LogFile = "log.txt"                             ' Keep a session log

' Open a connection to the SMTP server
objSmtp.SetSecure
objSmtp.Connect "smtp.gmail.com", "me@gmail.com", "password"
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If

' Compose an email message
objMail.FromAddress = "me@gmail.com"
objMail.FromName = "My Name"
objMail.Subject = "Hi !"
objMail.BodyPlainText = "Hello, How are you doing ?"
objMail.BodyHtml = "<html><body><h2>Hello</h2><p>How are you doing ?</p></body></html>"
objMail.AddTo "someone@example.com", "Someone"

' Send the email
objSmtp.Send objMail
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)    
End If

' Disconnect from the server
objSmtp.Disconnect
WScript.Echo "Done !"

5.2. Properties

Property Type Read/Write Description
Version String Read Version number of the ActiveXperts Email Component
Build String Read Build number of the ActiveXperts Email Component
Module String Read Module name of the ActiveXperts Email Component
LicenseStatus String Read License Status
LicenseKey String In/Out License Key
LastError Number Read Result of the last called method
LogFile String Read/Write The path to a logfile which can be used for troubleshooting
HostPort Number Read/Write The host port of the SMTP server to connect to
Authentication Number Read/Write The SMTP authentication method
UseStartTls Boolean Read/Write Use a secure connection if possible
LastSmtpResponse String Read Last SMTP response from the server
TimeoutConnect Number Read/Write Timeout (msecs) for a connection to be established
TimeoutAuthentication Number Read/Write Timeout (msecs) to authenticate
TimeoutCommand Number Read/Write Timeout (msecs) for each SMTP command to complete
TimeoutData Number Read/Write Timeout (msecs) for the SMTP DATA command to complete

Version property

Return the version number of the ActiveXperts Email Component

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Wscript.Echo "ActiveXperts Email Component Version " & objSmtp.Version & "; Build " & _
  objSmtp.Build & "; Module " & objSmtp.Module
WScript.Echo "License Status: " & objSmtp.LicenseStatus & vbCrLf
...

Build property

Return the build number of the ActiveXperts Email Component.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Wscript.Echo "ActiveXperts Email Component Version " & objSmtp.Version & "; Build " & _
  objSmtp.Build & "; Module " & objSmtp.Module
WScript.Echo "License Status: " & objSmtp.LicenseStatus & vbCrLf
...

Module property

Return the module name of the ActiveXperts Email Component.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Wscript.Echo "ActiveXperts Email Component Version " & objSmtp.Version & "; Build " & _
  objSmtp.Build & "; Module " & objSmtp.Module
WScript.Echo "License Status: " & objSmtp.LicenseStatus & vbCrLf
...

LicenseStatus property

The status of your license. In case you have not licensed the product, the property holds the trial expiration date. For details, see Product Activation.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")                 ' Create new instance
WScript.Echo "License Status: " & objSmtp.LicenseStatus
WScript.Echo "License Key: " & objSmtp.LicenseKey

LicenseKey property

A license key is required to unlock this component after the trial period has expired. Assign the LicenseKey property every time a new instance of this component is created (see code below). Alternatively, the LicenseKey property can be set automatically. This requires the license key to be stored in the registry. For details, see Product Activation.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")                 ' Create new instance
objSmtp.LicenseKey = "XXXXX-XXXXX-XXXXX"                ' Assign your license key 
WScript.Echo "LicenseKey: " & objSmtp.LicenseKey

LastError property

Completion code of the last called function. To find the error description of a given error code, go to the online error codes codes page.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Set objMail = CreateObject("AxEmail.Message")
...  
' Compose an email message
objMail.Subject = "Hi !"
objMail.BodyPlainText = "Hello, How are you doing ?"
objMail.BodyHtml = "<html><body><h2>Hello</h2><p>How are you doing ?</p></body></html>"
objMail.AddTo "someone@example.com", "Someone"
...
' Send the email
objSmtp.Send objMail
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)    
End If
...

LogFile property

By default, LogFile holds an empty string and nothing is logged. If a valid file name is assigned to it, the ActiveXperts Email Component will write debug information to this file. Output data is written at the end of the file, the file is not cleared.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
objSmtp.LogFile = "C:\temp\log.txt"
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
...

HostPort property

This is the host port of the SMTP server to connect to. Set this property if the port is different from the standard SMTP port (25).

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Set objMail = CreateObject("AxEmail.Message")
...
objSmtp.HostPort = 8025
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

Authentication property

This is the authentication method that should be used. By default the preferred authentication method will be automatically detected.

Use one of these constants.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Set objConst = CreateObject("AxEmail.Constants")
Set objMail = CreateObject("AxEmail.Message")
...
objSmtp.Authentication = objConst.SMTP_AUTH_MD5CRAM
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

UseStartTls property

Use a secure connection if supported by the SMTP server.
If the proprty is set to True, Connect will start a secure connection if the SMTP server supports it.
If the proprty is set to False, Connect will NOT start a secure connection, even in case the SMTP does support it.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Set objConst = CreateObject("AxEmail.Constants")
...
Set objSmtp.UseStartTls = False
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

LastSmtpResponse property

The last SMTP response from the server

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
Set objConst = CreateObject("AxEmail.Constants")
Set objMail = CreateObject("AxEmail.Message")
...  
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
WScript.Echo "Server response: " & objSmtp.LastSmtpResponse
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

TimeoutConnect property

Timeout (in milliseconds) for a connection to be established.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
...  
objSmtp.TimeoutConnect = 10000
objSmtp.Connect "smtp.example.com", "", ""
WScript.Echo "Server response: " & objSmtp.LastSmtpResponse
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

TimeoutAuthentication property

Timeout (in milliseconds) to authenticate to the SMTP mail server.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
...  
objSmtp.TimeoutAuthentication = 10000  
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
WScript.Echo "Server response: " & objSmtp.LastSmtpResponse
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

TimeoutCommand property

Timeout (in milliseconds) for each SMTP command to complete. This applies to all SMTP commands (e.g.: AUTH, RCPT TO, QUIT) except the DATA command.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
...  
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
... 
objSmtp.TimeoutCommand = 5000  
objSmtp.Send( objMail )
...

TimeoutData property

Timeout (msecs) for the SMTP DATA command to complete.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")
...  
objSmtp.Connect "smtp.example.com", "me@example.com", "password"
...  
objSmtp.TimeoutData = 120000   
objSmtp.Send( objMail )
...

5.3. Methods

Method Description
Clear Reset all properties to their default values
SaveLicenseKey Save the License Key in the registry
GetErrorDescription Get the description of the given error
Sleep Sleep for the specified number of milliseconds
SetSecure Enables TLS/SSL and sets the correct port number
Connect Connect to the SMTP server
Disconnect Disconnect from the SMTP server
Send Send an email message

Clear method

This function resets all properties to their default values.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objSmtp = CreateObject("AxEmail.Smtp")   
....
objSmtp.Clear
...

SaveLicenseKey method

Description:

Use SaveLicenseKey to store the license key permanently in the registry. When a license key is saved, it is restored automatically every time a new instance of the object is created. It is not recommended to save the license key if you distribute the component with your own software, because the key can be easily used by others.

Parameters:

  • None.
Return value:

Always 0. Check LastError property to see if the method was completed successfully.

Example:

Set objSmtp = CreateObject("AxEmail.Smtp")                 ' Create new instance
objSmtp.LicenseKey = "XXXXX-XXXXX-XXXXX"
objSmtp.SaveLicenseKey                                     ' Save license key to registry

For more information, see Product Activation.

GetErrorDescription method

GetErrorDescription provides the error description of a given error code.

Parameters:

  • The error code

Return value:

The error string.

Example:
Set objSmtp = CreateObject("AxEmail.Smtp")
...
WScript.Echo "result: " & objSmtp.LastError & ", " & _
  objSmtp.GetErrorDescription(objSmtp.LastError)

Sleep method

This function suspends the current thread for the specified number of milliseconds.

Parameters:

  • Milliseconds to sleep

Return value:

Always 0.

Example:
Set objSmtp = CreateObject("AxEmail.Smtp")
....
objSmtp.Sleep 1000
...

SetSecure method

This function makes sure TLS/SSL is enabled and the port number to connect on is set correctly.

Parameters:

  • (Optional) Port number, default: 465

Return value:

Always 0.

Example:
Set objSmtp = CreateObject("AxEmail.Smtp")
Set objMail = CreateObject("AxEmail.Message")
...  
objSmtp.SetSecure
objSmtp.Connect "smtp.gmail.com", "me@gmail.com", "password"
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

Connect method

This function connects to the specified SMTP server

Parameters:

  • Hostname
  • Account name
  • Password

Return value:

Always 0.

Example:
Set objSmtp = CreateObject("AxEmail.Smtp")
Set objMail = CreateObject("AxEmail.Message")
...  
objSmtp.Connect "smtp.gmail.com", "me@gmail.com", "password"
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...

Disconnect method

This function disconnects from the SMTP server

Parameters:

  • None

Return value:

Always 0.

Example:
Set objSmtp = CreateObject("AxEmail.Smtp")
Set objMail = CreateObject("AxEmail.Message")
...  
objSmtp.Connect "smtp.gmail.com", "me@gmail.com", "password"
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)  
  WScript.Quit
End If
...
objSmtp.Disconnect

Send method

This functions sends the specified email.

Parameters:

  • EMail object

Return value:

Always 0.

Example:
Set objSmtp = CreateObject("AxEmail.Smtp")
Set objMail = CreateObject("AxEmail.Message")
...
objMail.BodyPlainText = "Hello, How are you doing ?"
objMail.BodyHtml = "<html><body><h2>Hello</h2><p>How are you doing ?</p></body></html>"
objMail.AddTo "someone@example.com", "Someone"
...
objSmtp.Send objMail
If objSmtp.LastError <> 0 Then
  WScript.Echo "Error: " & objSmtp.GetErrorDescription(objSmtp.LastError)    
End If
...

6. Pop3

6.1. Introduction

The Pop3 object can be used to connect to a POP3 server and receive email messages.

Receive emails through POP3

Receive email messages through the POP3 protocol

Set objPop3 = CreateObject("AxEmail.Pop3")          ' Create the POP3 protocol object
Set objMail = CreateObject("AxEmail.Message")       ' Create the email message object

Wscript.Echo "ActiveXperts Email Component Version " & objPop3.Version & "; Build " & _
  objPop3.Build & "; Module " & objPop3.Module
WScript.Echo "License Status: " & objPop3.LicenseStatus & vbCrLf

objPop3.LogFile = "log.txt"                         ' Keep a session log

' Open a connection to the POP3 server
objPop3.SetSecure
objPop3.Connect "pop.gmail.com", "me@gmail.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If

' Retrieve all new messages
For i = 1 to objPop3.CountMessages()
  Set objMail = objPop3.GetEmailMessage(i)
  If objPop3.LastError <> 0 Then
    WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
    objPop3.Disconnect
    WScript.Quit
  End If  
  
  WScript.Echo "--------------------------------------------------------------"
  WScript.Echo objMail.Date
  WScript.Echo objMail.FromAddress
  WScript.Echo objMail.Subject
  WScript.Echo objMail.BodyPlainText
  
  For j = 1 to objMail.CountAttachments()
    strName = objMail.GetAttachmentName(j)
    WScript.Echo "  Attachment found: " & strName
    ' Uncomment the following lines to save the attachments.
    'strPath = "C:\Temp\" & strName
    'WScript.Echo "  Saving attachment to : " & strPath
    'objMail.SaveAttachment j, strPath
  Next    
Next

objPop3.Disconnect
WScript.Echo "Disconnected"

6.2. Properties

Property Type Read/Write Description
Version String Read Version number of the ActiveXperts Email Component
Build String Read Build number of the ActiveXperts Email Component
Module String Read Module name of the ActiveXperts Email Component
LicenseStatus String Read License Status
LicenseKey String In/Out License Key
LastError Number Read Result of the last called method
LogFile String Read/Write The path to a logfile which can be used for troubleshooting
HostPort Number Read/Write The host port for the POP3 server
Authentication Number Read/Write The authentication method
LastPop3Response String Read/Write The host port for the POP3 server
TimeoutConnect Number Read/Write Timeout (msecs) for a connection to be established
TimeoutAuthentication Number Read/Write Timeout (msecs) to authenticate
TimeoutCommand Number Read/Write Timeout (msecs) for each POP3 command to complete
TimeoutData Number Read/Write Timeout (msecs) for the POP3 RETR command to complete

Version property

Return the version number of the ActiveXperts Email Component

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
Wscript.Echo "ActiveXperts Email Component Version " & objPop3.Version & "; Build " & _
  objPop3.Build & "; Module " & objPop3.Module
WScript.Echo "License Status: " & objPop3.LicenseStatus & vbCrLf
...

Build property

Return the build number of the ActiveXperts Email Component.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
Wscript.Echo "ActiveXperts Email Component Version " & objPop3.Version & "; Build " & _
  objPop3.Build & "; Module " & objPop3.Module
WScript.Echo "License Status: " & objPop3.LicenseStatus & vbCrLf
...

Module property

Return the module name of the ActiveXperts Email Component.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
Wscript.Echo "ActiveXperts Email Component Version " & objPop3.Version & "; Build " & _
  objPop3.Build & "; Module " & objPop3.Module
WScript.Echo "License Status: " & objPop3.LicenseStatus & vbCrLf
...

LicenseStatus property

The status of your license. In case you have not licensed the product, the property holds the trial expiration date. For details, see Product Activation.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")                 ' Create new instance
WScript.Echo "License Status: " & objPop3.LicenseStatus
WScript.Echo "License Key: " & objPop3.LicenseKey

LicenseKey property

A license key is required to unlock this component after the trial period has expired. Assign the LicenseKey property every time a new instance of this component is created (see code below). Alternatively, the LicenseKey property can be set automatically. This requires the license key to be stored in the registry. For details, see Product Activation.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")                 ' Create new instance
objPop3.LicenseKey = "XXXXX-XXXXX-XXXXX"                ' Assign your license key 
WScript.Echo "LicenseKey: " & objPop3.LicenseKey

LastError property

Completion code of the last called function. To find the error description of a given error code, go to the online error codes codes page.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
objPop3.Connect "pop.example.com", "me@example.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

LogFile property

By default, LogFile holds an empty string and nothing is logged. If a valid file name is assigned to it, the ActiveXperts Email Component will write debug information to this file. Output data is written at the end of the file, the file is not cleared.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
objPop3.LogFile = "C:\Temp\Pop3.log"
objPop3.Connect "pop.example.com", "me@example.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

HostPort property

Set the host port to connect to. By default this is 110.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")

objPop3.HostPort = 8110
objPop3.Connect "pop.example.com", "me@example.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

Authentication property

Set the authentication method to use on the POP3 server. By default it will autodetect the preferred method.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")

objPop3.Authentication = POP3_AUTH_PLAIN
objPop3.Connect "pop.example.com", "me@example.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

LastPop3Response property

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")

objPop3.Connect "pop.example.com", "me@example.com", "password"
WScript.Echo "Server reponse: " & objPop3.LastPop3Response
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

TimeoutConnect property

Timeout (in milliseconds) for a connection to be established.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
objPop3.TimeoutConnect = 10000
objPop3.Connect "pop.example.com", "me@example.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

TimeoutAuthentication property

Timeout (in milliseconds) to authenticate to the POP3 mail server.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
objPop3.TimeoutAuthentication = 10000
objPop3.Connect "pop.example.com", "me@example.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

TimeoutCommand property

Timeout (in milliseconds) for each POP3 command to complete. This applies to all POP3 commands (e.g.: APOP, CAPA, QUIT) except the RETR command.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
objPop3.TimeoutCommand = 10000      
For i = 1 to objPop3.CountMessages()
  Set objMail = objPop3.GetEmailMessage(i)
  If objPop3.LastError <> 0 Then
    WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
    objPop3.Disconnect
    WScript.Quit
  End If  

  WScript.Echo "--------------------------------------------------------------"
  WScript.Echo objMail.Date
  WScript.Echo objMail.FromAddress
  WScript.Echo objMail.Subject
  WScript.Echo objMail.BodyPlainText
Next
...

TimeoutData property

Timeout (msecs) for the POP3 RETR command to complete.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")
objPop3.TimeoutData = 120000      
For i = 1 to objPop3.CountMessages()
  Set objMail = objPop3.GetEmailMessage(i)
  If objPop3.LastError <> 0 Then
    WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
    objPop3.Disconnect
    WScript.Quit
  End If  

  WScript.Echo "--------------------------------------------------------------"
  WScript.Echo objMail.Date
  WScript.Echo objMail.FromAddress
  WScript.Echo objMail.Subject
  WScript.Echo objMail.BodyPlainText
Next
...

6.3. Methods

Method Description
Clear Reset all properties to their default values
SaveLicenseKey Save the License Key in the registry
GetErrorDescription Get the description of the given error
Sleep Sleep for the specified number of milliseconds
SetSecure Enable TLS/SSL and set the correct port number
Connect Connect to the specified POP3 server
Disconnect Disconnect from the POP3 server
IsConnected Returns the connected state
CountMessages Count the number of messages in the mail-drop
DeleteMessage Delete a message from the mail-drop
GetEmailHeader Retrieve the email header
GetEmailMessage Retrieve the email message

Clear method

This function resets all properties to their default values.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")   
....
objPop3.Clear
...

SaveLicenseKey method

Description:

Use SaveLicenseKey to store the license key permanently in the registry. When a license key is saved, it is restored automatically every time a new instance of the object is created. It is not recommended to save the license key if you distribute the component with your own software, because the key can be easily used by others.

Parameters:

  • None.
Return value:

Always 0. Check LastError property to see if the method was completed successfully.

Example:

Set objPop3 = CreateObject("AxEmail.Pop3")                 ' Create new instance
objPop3.LicenseKey = "XXXXX-XXXXX-XXXXX"
objPop3.SaveLicenseKey                                     ' Save license key to registry

For more information, see Product Activation.

GetErrorDescription method

GetErrorDescription provides the error description of a given error code.

Parameters:

  • The error code

Return value:

The error string.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
...
WScript.Echo "result: " & objPop3.LastError & ", " & _
  objPop3.GetErrorDescription(objPop3.LastError)

Sleep method

This function suspends the current thread for the specified number of milliseconds.

Parameters:

  • Milliseconds to sleep

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
...
objPop3.Sleep 1000
...

SetSecure method

This function enables TLS/SSL and sets the correct port number.

Parameters:

  • Port number. Default: 995

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...
objPop3.SetSecure
objPop3.Connect "pop.gmail.com", "me@gmail.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

Connect method

This function connects to the POP3 server.

Parameters:

  • Hostname
  • Account
  • Password

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...  
objPop3.Connect "pop.gmail.com", "me@gmail.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...

Disconnect method

This function disconnects from the POP3 server.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...  
objPop3.Connect "pop.gmail.com", "me@gmail.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...
objPop3.Disconnect

IsConnected method

This function returns the connected state. True is connected, False if not connected.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...  
objPop3.Connect "pop.gmail.com", "me@gmail.com", "password"
If objPop3.LastError <> 0 Then
  WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
  WScript.Quit
End If
...
WScript.Echo objPop3.IsConnected
...
objPop3.Disconnect

CountMessages method

This function requests the number of messages in the mail drop.

Parameters:

  • None

Return value:

The number of messages in the mail-drop

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...
For i = 1 to objPop3.CountMessages()
  Set objMail = objPop3.GetEmailMessage(i)
  If objPop3.LastError <> 0 Then
    WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
    objPop3.Disconnect
    WScript.Quit
  End If  
  
  WScript.Echo "--------------------------------------------------------------"
  WScript.Echo objMail.Date
  WScript.Echo objMail.FromAddress
  WScript.Echo objMail.Subject
  WScript.Echo objMail.BodyPlainText    
Next
...

DeleteMessage method

This function deletes a message from the mail-drop. This prevents the mail server from including this email on the next connect.

Parameters:

  • Message Id

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...
For i = 1 to objPop3.CountMessages()
  Set objMail = objPop3.GetEmailMessage(i)
  If objPop3.LastError <> 0 Then
    WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
    objPop3.Disconnect
    WScript.Quit
  End If  
  
  WScript.Echo "--------------------------------------------------------------"
  WScript.Echo objMail.Date
  WScript.Echo objMail.FromAddress
  WScript.Echo objMail.Subject
  WScript.Echo objMail.BodyPlainText
  
  objPop3.DeleteMessage objMessage.ID
Next
...

GetEmailHeader method

This function only returns the email header. On most mail servers this will be faster than retrieving the entire message body.

Parameters:

  • Message Id

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...
For i = 1 to objPop3.CountMessages()
  Set objMail = objPop3.GetEmailHeader(i)
  If objPop3.LastError <> 0 Then
    WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
    objPop3.Disconnect
    WScript.Quit
  End If  
  
  WScript.Echo "--------------------------------------------------------------"
  WScript.Echo objMail.Date
  WScript.Echo objMail.FromAddress
  WScript.Echo objMail.Subject    
Next
...

GetEmailMessage method

This function retrieves the email message

Parameters:

  • Message Id

Return value:

Always 0.

Example:
Set objPop3 = CreateObject("AxEmail.Pop3")
Set objMail = CreateObject("AxEmail.Message")
...
For i = 1 to objPop3.CountMessages()
  Set objMail = objPop3.GetEmailMessage(i)
  If objPop3.LastError <> 0 Then
    WScript.Echo "Error: " & objPop3.GetErrorDescription(objPop3.LastError)  
    objPop3.Disconnect
    WScript.Quit
  End If  
  
  WScript.Echo "--------------------------------------------------------------"
  WScript.Echo objMail.Date
  WScript.Echo objMail.FromAddress
  WScript.Echo objMail.Subject
  WScript.Echo objMail.BodyPlainText
Next
...

7. Message

7.1. Introduction

The Message object represents an email message. The POP3 protocol receives email messages and the SMTP protocol can be used to send email messages.

7.2. Properties

Property Type Read/Write Description
LastError Number Read Result of the previously called function
Subject String Read/Write The Subject of the message
BodyPlainText String Read/Write The plain-text body of the message
BodyHtml String Read/Write The html body of the message
Priority Number Read/Write The Priority of the message.
FromName String Read/Write The sender's name
FromAddress String Read/Write The sender's email address
ReplyAddress String Read/Write The Sender's reply-address.
ReadReceiptAddress String Read/Write Email address to send a read receipt to
Organization String Read/Write The sender's organization name
MessageSource String Read The source of the email message
MessageHeader String Read The header of the email message
Size Number Read The sender's organization name
Date String Read The email date
ToAddress String Read The 'To' address(es)
CcAddress String Read The 'Cc' address(es)
BccAddress String Read The 'Bcc' address(es)
Encoding Number Read/Write SMTP specific. Encoding used to send create this message
ID Number Read POP3 specific, The email index on the server

LastError property

This read-only property indicates the result of the last called function. A zero indicates: success. Any non-zero value means an error.

For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.

Example:

Set objSmtpMail = CreateObject("AxEmail.Message")
...
objMessage.AddAttachment("C:\File.txt")
WScript.Echo "Result code: " & objMessage.LastError
...

Subject property

This is the subject of the email message.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
objMessage.Subject = "This is an important message"
...

BodyPlainText property

This is the plain text body of the message. When sending email, set this property to the plain text part of the email message. When receiving email, this property will be set to the plain text part if a plain text part is available.

Example:

Set objEMail = CreateObject("AxEmail.Message")
Set objConstants = CreateObject("AxEmail.Components")
...
objEMail.AddAttachment "C:\MySelf.jpg"
objEMail.AddAttachment "C:\MyWife.jpg"
objEMail.BodyPlainText = "Find a picture of myself and my wife attached to this email."
objEMail.BodyHtml = "<html><body>This <img SRC="cid:1"> is me" &_
                    "<br>and <img SRC="cid:2"> my wife<br></body></html>"
...

BodyHtml property

This is the HTML body of the message. When sending email, set this property to the HTML part of the email message. When receiving email, this property will be set to the HTML part if a HTML part is available.

Example:

Set objEMail = CreateObject("AxEmail.Message")
Set objConstants = CreateObject("AxEmail.Components")
...
objEMail.AddAttachment "C:\MySelf.jpg"
objEMail.AddAttachment "C:\MyWife.jpg"
objEMail.BodyPlainText = "Find a picture of myself and my wife attached to this email."
objEMail.BodyHtml = "<html><body>This <img SRC="cid:0000001"> is me" &_
                           "<br>and <img SRC="cid:0000002"> my wife<br></body></html>"
...

Priority property

The email priority. This can be used by the email client, such as outlook, to control how to display this email.

Example:

Set objMessage = CreateObject("AxEmail.Message")
Set objConstants = CreateObject("AxEmail.Components")
...
objMessage.Priority =  objConstants.EMAIL_MESSAGE_PRIORITY_HIGH
...

FromName property

The name of the email sender. This file can be left empty.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
objMessage.FromAddress = "me@mydomain.doc"
objMessage.FromName = "This is Me"
...

FromAddress property

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
objMessage.FromAddress = "me@mydomain.doc"
objMessage.FromName = "This is Me"
...

ReplyAddress property

The sender's reply address. If this is left empty the from address will be used as the reply address.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
objMessage.ReplyAddress = "myself@mydomain.com"
...

ReadReceiptAddress property

Email address of the person who should receive a 'read receipt'. The receipt is sent when the message recipient has displayed your message. This is useful when you are sending time-critical information, or any time you want confirmation that your message has been received.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
objMessage.ReadReceiptAddress = "myself@mydomain.com"
...

Organization property

This is the sender name of the organization of the sender.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
objMessage.Organization = "My Organization"
...

MessageSource property

This is the source of the email message.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.MessageSource
...

MessageHeader property

This is the header of the email message.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.MessageHeader
...

Size property

This is the sender name of the organization of the sender.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.Size
...

Date property

This returns the email date field.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.Date
...

ToAddress property

Returns a 'comma seperated' string of 'To' addresses for this email.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.ToAddress
WScript.Echo objMessage.CcAddress
WScript.Echo objMessage.BccAddress
...

CcAddress property

Returns a 'comma seperated' string of 'Cc' addresses for this email.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.ToAddress
WScript.Echo objMessage.CcAddress
WScript.Echo objMessage.BccAddress
...

BccAddress property

Returns a 'comma seperated' string of 'Bcc' addresses for this email.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.ToAddress
WScript.Echo objMessage.CcAddress
WScript.Echo objMessage.BccAddress
...

Encoding property

When creating a message using a specific extended ASCII encoding, like ISO-8859-6 (Arabic), use this property to set the encoding to the proper value.

Use one of these values.

Example:

Set objMessage = CreateObject("AxEmail.Message")
Set objConstants = CreateObject("AxEmail.Components")
...
objMessage.Encoding = objConstants.EMAIL_MESSAGE_ENCODING_ARABIC
...

ID property

This is the index in the mail-drop on the POP3 server.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.ID  
...

7.3. Methods

Method Description
Clear Reset all properties to their default values
AddHeader Add an additional header value to the email
GetHeaderValue Get a header value from the email
AddTo Add an email recipient
AddCc Add a 'Carbon Copy' recipient
AddBcc Add a 'Blind Carbon Copy' recipient
AddAttachment Add an attachment to the email
CountAttachments Number of attachments attached to the email
GetAttachmentName Get the name of an attachment
GetAttachmentSize Get the size of an attachment
SaveAttachment Save the attachment to a file
Encode Encode an email to mime
Decode Decode the given email
LoadMIME Load a MIME file
SaveMIME Save a MIME file

Clear method

This function resets all properties to their default values.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.Clear
...

AddHeader method

This function will add a header value to the email.

Parameters:

  • Name
  • Value

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.AddHeader "X-Bender", "Bite my shiny metal ass."
...

GetHeaderValue method

This function returns the given header value if it can be found.

Parameters:

  • None

Return value:

The header value.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
WScript.Echo objMessage.GetHeader("X-UIDL")
...

AddTo method

This functions adds an email recipient to the email.

Parameters:

  • Email address
  • Display name

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.AddTo "someone@example.com", "Someone"
objMessage.AddCc "myboss@example.com", "My Boss"
objMessage.AddBcc "coworker@example.com", "Co Worker"
...

AddCc method

This function adds a recipient to the 'Carbon Copy' (CC) list.

Parameters:

  • Email address
  • Display name

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.AddTo "someone@example.com", "Someone"
objMessage.AddCc "myboss@example.com", "My Boss"
objMessage.AddBcc "coworker@example.com", "Co Worker"
...

AddBcc method

This function adds a recipient to the 'Blind Carbon Copy' (BCC) list

Parameters:

  • Email address
  • Display name

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.AddTo "someone@example.com", "Someone"
objMessage.AddCc "myboss@example.com", "My Boss"
objMessage.AddBcc "coworker@example.com", "Co Worker"
...

AddAttachment method

This function adds an attachment to the email.

Parameters:

  • Filename of the attachment

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.AddAttachment "C:\Temp\file.zip"
If objMessage.LastError <> 0 Then
  WScript.Echo "Error: " & objMessage.GetErrorDescription(objMessage.LastError)
End If
...

CountAttachments method

This function counts the number of attachments on this email

Parameters:

  • none

Return value:

The number of attachments

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
For j = 1 to objMail.CountAttachments()
  strName = objMail.GetAttachmentName(j)
  WScript.Echo "  Attachment found: " & strName
  strPath = "C:\Temp\" & strName
  WScript.Echo "  Saving attachment to : " & strPath
  objMail.SaveAttachment j, strPath
Next  
...

GetAttachmentName method

This function returns the filename of the attachment identified by the given ID. If the filename is not available it will return the name of the attachment.

The ID of the attachment ranges from 1 to CountAttachments

Parameters:

  • Attachment ID

Return value:

The name of the attachment

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
For j = 1 to objMail.CountAttachments()
  strName = objMail.GetAttachmentName(j)
  WScript.Echo "  Attachment found: " & strName
  strPath = "C:\Temp\" & strName
  WScript.Echo "  Saving attachment to : " & strPath
  objMail.SaveAttachment j, strPath
Next  
...

GetAttachmentSize method

This function returns the size of the attachment identified by the given ID. This is the size of the attachment before it is decoded.

The ID of the attachment ranges from 1 to CountAttachments

Parameters:

  • Attachment ID

Return value:

The size of the attachment

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
For j = 1 to objMail.CountAttachments
  strName = objMail.GetAttachmentName(j)
  WScript.Echo "  Attachment found: " & strName & "; Size: " & objMail.GetAttachmentSize(j)
  strPath = "C:\Temp\" & strName
  WScript.Echo "  Saving attachment to : " & strPath
  objMail.SaveAttachment j, strPath
Next  
...

SaveAttachment method

This function saves the attachment identified by the given Id.

The ID of the attachment ranges from 1 to CountAttachments

Parameters:

  • Attachment ID
  • Filename to save the attachment to

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
For j = 1 to objMail.CountAttachments
  strName = objMail.GetAttachmentName(j)
  WScript.Echo "  Attachment found: " & strName
  strPath = "C:\Temp\" & strName
  WScript.Echo "  Saving attachment to : " & strPath
  objMail.SaveAttachment j, strPath
Next  
...

Encode method

This function actually encodes the email to the MIME format.

If you are creating a MIME encoded message to send it out at a later time always call this function before calling SaveMIME.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.Encode
...

Decode method

This function will decode a MIME file.

This function is automatically called when receiving or loading a MIME encoded message. This function never needs to be called.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.Decode
...

LoadMIME method

This function loads a MIME encoded email from file.

Parameters:

  • The file name to load from

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.LoadMIME "C:\Temp\Test.mime"
If objMessage.LastError <> 0 Then
  WScript.Echo "Error: " & objMessage.GetErrorDescription(objMessage.LastError)
End If  
...

SaveMIME method

This function saves a MIME encoded file

Parameters:

  • The filename to save to

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.SaveMIME "C:\Temp\Test.mime"
If objMessage.LastError <> 0 Then
  WScript.Echo "Error: " & objMessage.GetErrorDescription(objMessage.LastError)
End If  
...

8. Constants

8.1. Introduction

In the ActiveXperts Email Component, all email constants are grouped together in a separate object called Constants. First create the constants object before you can actually use the constants:

Set objConstants = CreateObject("AxEmail.Constants")
...
WScript.Echo objConstants.EMAIL_MESSAGE_PRIORITY_HIGHEST
WScript.Echo objConstants.EMAIL_MESSAGE_PRIORITY_HIGH
WScript.Echo objConstants.EMAIL_MESSAGE_PRIORITY_MEDIUM
WScript.Echo objConstants.EMAIL_MESSAGE_PRIORITY_LOW
WScript.Echo objConstants.EMAIL_MESSAGE_PRIORITY_LOWEST
...

8.2. Constants

Priority definitions

Constant Value Description
EMAIL_MESSAGE_PRIORITY_HIGHEST Highest priority
EMAIL_MESSAGE_PRIORITY_HIGH High priority
EMAIL_MESSAGE_PRIORITY_MEDIUM Normal priority (default)
EMAIL_MESSAGE_PRIORITY_LOW Low priority
EMAIL_MESSAGE_PRIORITY_LOWEST Lowest priority

Encoding definitions

Constant Value Description
EMAIL_MESSAGE_ENCODING_DEFAULT Uses the Operating System's current codepage
EMAIL_MESSAGE_ENCODING_THAI ISO-8859-11 encoding
EMAIL_MESSAGE_ENCODING_JAPANESE ISO-2022-jp encoding
EMAIL_MESSAGE_ENCODING_CHINESE_SIMP GB2312 encoding
EMAIL_MESSAGE_ENCODING_KOREAN KSC-5601 encoding
EMAIL_MESSAGE_ENCODING_CHINESE_TRAD BIG5 encoding
EMAIL_MESSAGE_ENCODING_CENTRALEUROPE ISO-8859-2 encoding
EMAIL_MESSAGE_ENCODING_RUSSIAN ISO-8859-5 encoding
EMAIL_MESSAGE_ENCODING_WESTERN ISO-8859-1 encoding
EMAIL_MESSAGE_ENCODING_GREEK ISO-8859-7 encoding
EMAIL_MESSAGE_ENCODING_TURKISH ISO-8859-3 encoding
EMAIL_MESSAGE_ENCODING_HEBREW ISO-8859-8 encoding
EMAIL_MESSAGE_ENCODING_ARABIC ISO-8859-6 encoding
EMAIL_MESSAGE_ENCODING_BALTIC ISO-8859-4 encoding
EMAIL_MESSAGE_ENCODING_VIETNAMESE WINDOWS-1258 encoding
EMAIL_MESSAGE_ENCODING_UTF7 UTF-7 encoding
EMAIL_MESSAGE_ENCODING_UTF8 UTF-8 encoding

SMTP Authentication definitions

Constant Value Description
SMTP_AUTH_AUTO Auto detect (default)
SMTP_AUTH_PLAIN AUTH-PLAIN authentication
SMTP_AUTH_LOGIN AUTH-LOGIN authentication
SMTP_AUTH_MD5CRAM AUTH-CRAM-MD5 authentication

POP3 Authentication definitions

Constant Value Description
POP3_AUTH_AUTO Auto detect (default)
POP3_AUTH_PLAIN AUTH-PLAIN authentication
POP3_AUTH_APOP APOP authentication

9. Support

9.1. Product samples

Samples for Visual Basic, Visual Basic .NET, Visual C++, Visual C# .NET, ASP and VBScript are included as part of the installation. You can also find the samples on our ftp site at ftp://ftp.activexperts-labs.com/samples/smtp-pop3-component/.

9.2. ActiveXperts Support

Visit the ActiveXperts Support Site for a complete list of FAQ items at:
    http://www.activexperts.com/support

To contact support, please send an email to: support@activexperts.com

10. Purchase and Activation

10.1. Purchase

Please visit www.activexperts.com/sales to buy the product. Here, you can also find the latest prices.

You can also contact us via email: sales@activexperts.com

10.2. Product Activation

After purchasing the product, you will receive a license key.

There are four ways to activate (unlock) the component using this license key:

1. Directly from your program code

You can unlock the component by using the LicenseKey property. This way, the license is NOT stored in the registry of the computer. This is the recommended way when distributing this component with your own software.

2. Store the license key in the registry - Installation

When the license key is entered during Setup (AxEmailSetup.exe, available from the ActiveXperts download site), the license key will be saved in the following registry key:
'HKEY_LOCAL_MACHINE\Software\ActiveXperts\Email Component\LicenseKey'

Once the license key is stored in the registry, the LicenseKey property will be assigned automatically with that value each time the object is instantiated.

3. Store the license key in the registry - Manually

You can enter the license key manually (e.g. through REGEDIT.EXE) in following registry key:
'HKEY_LOCAL_MACHINE\Software\ActiveXperts\Email Component\LicenseKey'

Once the license key is stored in the registry, the LicenseKey property will be assigned automatically with that value each time the object is instantiated.

4. Store the license key in the registry - SaveLicenseKey method

You can enter the license key by calling the SaveLicenseKey method. You need to call SaveLicenseKey only once.

Set objSmtp = CreateObject("AxEmail.Smtp") ' Create new instance
objSmtp.LicenseKey = "XXXXX-XXXXX-XXXXX"  ' Replace XXXXX-XXXXX-XXXXX by your own key
objSmtp.SaveLicenseKey

Once the license key is stored in the registry, the LicenseKey property will be assigned automatically with that value each time the object is instantiated.

11. Appendix A - License agreement

11.1. License agreement

PLEASE READ THIS SOFTWARE LICENSE AGREEMENT CAREFULLY BEFORE 
DOWNLOADING OR USING THE SOFTWARE.  BY CLICKING ON THE 
"ACCEPT" BUTTON, OPENING THE PACKAGE, DOWNLOADING THE PRODUCT, 
OR USING THE EQUIPMENT THAT CONTAINS THIS PRODUCT, YOU ARE 
CONSENTING TO BE BOUND BY THIS AGREEMENT. IF YOU DO NOT AGREE 
TO ALL OF THE TERMS OF THIS AGREEMENT, CLICK THE "DO NOT 
ACCEPT" BUTTON AND THE INSTALLATION PROCESS WILL NOT CONTINUE, 
RETURN THE PRODUCT TO THE PLACE OF PURCHASE FOR A FULL REFUND, 
OR DO NOT DOWNLOAD THE PRODUCT.

GENERAL
In this Software License Agreement:
(i) "ActiveXperts" means ActiveXperts Software B.V.
(ii) "Customer" means the individual(s), organization or business entity 
buying a license of the Software from ActiveXperts or its Distributors 
or its Resellers.
(iii) "Software" means computer programs (and their storage medium) 
supplied by ActiveXperts and known collectively as "ActiveXperts Email Component" 
in which ActiveXperts has property rights and any user manuals, 
operating instructions, brochures and all other documentation relating 
to the said computer programs (the expression "Software" to include all 
or any part or any combination of Software).

1. LICENSE GRANT
ActiveXperts grants Customer the following rights provided that you 
comply with all terms and conditions of this License Agreement:

(a) Installation and use. Customer may install, use, access, display and 
run one copy of the Software on a single computer, such as a 
workstation, terminal or other device ("Workstation Computer"). A 
"License Pack" allows you to install, use, access, display and run 
additional copies of the Software up to the number of "Licensed Copies" 
specified above.

(b) Reservation of Rights. ActiveXperts reserves all rights not 
expressly granted to you in this License Agreement.

2. UPGRADES AND SUPPLEMENTS
To use a product identified as an upgrade, you must first be licensed 
for the Software as eligible for the upgrade. After upgrading, Customer 
may no longer use the product that formed the basis for Customer's 
upgrade eligibility.

This License Agreement applies to updates or supplements to the original 
Software provided by ActiveXperts, unless we provide other terms along 
with the update or supplement.

3. LIMITATION ON REVERSE ENGINEERING,DECOMPILATION, AND DISASSEMBLY
Customer may not reverse engineer, decompile, or disassemble the 
Software, except and only to the extent that it is expressly permitted 
by applicable law notwithstanding this limitation.

4. TERMINATION
Without prejudice to any other rights, ActiveXperts may cancel this 
License Agreement if Customer does not abide by the terms and conditions 
of this License Agreement, in which case you must destroy all copies of 
the Software and all of its component parts.

5. NOT FOR RESALE SOFTWARE
Software identified as "Not for Resale" or "NFR," may not be resold, 
transferred or used for any purpose other than demonstration, test or 
evaluation.

6. LIMITED WARRANTY
ActiveXperts warrants that for a period of ninety (90) days from the 
date of shipment from ActiveXperts: (i) the media on which the Software 
is furnished will be free of defects in materials and workmanship under 
normal use; and (ii) the Software substantially conforms to its 
published specifications. Except for the foregoing, the Software is 
provided AS IS. This limited warranty extends only to Customer as the 
original licensee. Customer's exclusive remedy and the entire liability 
of ActiveXperts and its suppliers under this limited warranty will be, 
at ActiveXperts or its service center's option, repair, replacement, or 
refund of the Software if reported (or, upon request, returned) to the 
party supplying the Software to Customer. In no event does ActiveXperts 
warrant that the Software is error free or that Customer will be able to 
operate the Software without problems or interruptions.
This warranty does not apply if the software (a) has been altered, 
except by ActiveXperts, (b) has not been installed, operated, repaired, 
or maintained in accordance with instructions supplied by ActiveXperts, 
(c) has been subjected to abnormal physical or electrical stress, 
misuse, negligence, or accident, or (d) is used in ultrahazardous 
activities.


7. LIMITATION OF LIABILITY AND REMEDIES.
Notwithstanding any damages that you might incur for any reason 
whatsoever (including, without limitation, all damages referenced above 
and all direct or general damages), the entire liability of ActiveXperts 
and any of its suppliers under any provision of this License Agreement 
and your exclusive remedy for all of the foregoing (except for any 
remedy of repair or replacement elected by ActiveXperts with respect to 
any breach of the Limited Warranty) shall be limited to the greater of 
the amount actually paid by you for the Software or U.S.$5.00. The 
foregoing limitations, exclusions and disclaimers (including Sections 4, 
5 and 6 above) shall apply to the maximum extent permitted by applicable 
law, even if any remedy fails its essential purpose.

8. ENTIRE AGREEMENT

This License Agreement (including any addendum or amendment to this 
License Agreements which is included with the Software) are the entire 
agreement between you and ActiveXperts relating to the Software and the 
support services (if any) and they supersede all prior or 
contemporaneous oral or written communications, proposals and 
representations with respect to the Software or any other subject matter 
covered by this License Agreement. To the extent the terms of any 
ActiveXperts policies or programs for support services conflict with the 
terms of this License Agreement, the terms of this License Agreement 
shall control.

This Agreement shall be construed in accordance with the laws of The 
Netherlands and the Dutch courts shall have sole jurisdiction in any 
dispute relating to these conditions. If any part of these conditions 
shall be or become invalid or unenforceable in any way and to any extent 
by any existing or future rule of law, order, statute or regulation 
applicable thereto, then the same shall to the extent of such invalidity 
or enforceability be deemed to have been deleted from the conditions 
which shall remain in full force and effect as regards all other 
provisions.

9. Copyright
The Software is protected by copyright and other intellectual property 
laws and treaties. ActiveXperts or its suppliers own the title, 
copyright, and other intellectual property rights in the Software. The 
Software is licensed, not sold.
© 2011 ActiveXperts Software B.V.   contact@activexperts.com