ActiveEmail E-mail Toolkit
Manual Pages


© 1999-2007 - ActiveXperts Software B.V.
http://www.activexperts.com
info@activexperts.com




Table of Contents

1. Introduction
2. System Requirements
3. Installation
4. Using ActiveEmail
5. Error Codes and Constants
6. SmtpServer Object
7. SmtpMail Object
8. Pop3Server Object
9. Pop3Mail Object
10. ActiveEmail Queue Server
11. Samples
12. Troubleshooting
13. Purchase and Product Activation
   
Appendix A: About MIME
Appendix B: License Agreement



1. Introduction

1.1. What is ActiveEmail?

ActiveEmail provides an easy-to-use scripting interface to SMTP and POP3 e-mail communications.
It's perfectly suited for situations in which e-mails have to be sent/received automatically, or in batches, from within applications, webservers, or from the command-line.
The performance of the engine is outstanding, due to its multi-threaded architecture and its (optional) queuing features. It has proven its strength in many business environments over the years.

ActiveEmail is an ActiveX/COM-component, that can be used in Windows programming environment, including:

1.2. ActiveEmail features

The following features are supported by ActiveEmail:

1.3. ActiveEmail Architecture

ActiveEmail 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 ActiveEmail consists of two files:

ActiveEmail can be distributed easily to many PC's. Once you have purchased the licenses, you copy the AEmail.dll to the PCs and register the DLL on that PC.



2. System Requirements

The ActiveEmail component can be used by many Windows development platforms, including:

2.1. .NET Framework

To use ActiveEmail in an ASP .NET, Visual Basic .NET or Visual C#. NET environment, the .NET Framework must be installed on the system. The .NET Framework is part of the Windows 2003 Operating System. On Windows 2000, Windows 98, Windows ME, Windows NT, Windows Server 2003, Windows XP, it's available as a separate installation. Please visit the Technology Information for the .NET Framework page to download the .NET Framework.

2.2. Internet Information Server

Internet Information Server (IIS) Setup installs the Visual Basic Script and Java Script engines.

To run ASP pages on NT4 Servers, IIS 4.x must be installed. IIS 4.x ships with the NT4 Option Pack CD's.
To run ASP pages on Windows 2000 Servers, IIS 5.x must be installed. IIS is part of the Windows 2000 Operating System.

2.3. Internet Explorer 4.x or higher

The Internet Explorer 4.x Setup (or higher) installs the Visual Basic Script and Java Script engines.
You can use the ActiveEmail component from within the client HTML code.

2.4. Windows Scripting Host

ActiveEmail can be used in VBScript scripts. VBScripts can be used by passing the script-file as a parameter to the scripting host ( either 'cscript' or 'wscript').
WSH relies on the Visual Basic Script and Java Script engines provided with Internet Explorer 4.x or later. WSH is also installed as part of Windows 98, Windows 2000, and Internet Information Services 4.0. A separate setup program is provided for Windows 95.

2.5. Visual Basic

ActiveEmail can be used in Visual Basic 5.x or higher.

2.6. Visual C++

ActiveEmail can be used in Visual C++ 5.x or higher.



3. Installation

The ActiveEmail package consists of 4 components; any combination of components can be installed:

3.1. Installation on a single computer

Simply run the AEmail.exe Setup program. The InstallShield wizard will guide you through the rest of the setup.
If you choose the ActiveEmail COM component, the Setup program can perform the registration of the COM component for you. But it will also give you the opportunity to register the object yourself;

If you choose the ActiveEmail Queue Server service, the Setup can install the service for you. But it will also give you the opportunity to install the service yourself, for instance by using the INSTSVR Resource Kit utility;

Any subsequent installation of ActiveEmail can be performed either manually or by using the Setup program.

3.2. Installation on multiple computers

Any subsequent installations can be performed using the setup program.
But since the installation of the core components is very simple, you may want to do it manually, or integrate it into your companies software distribution program.

If you choose to install the COM component manually on other machines, simply perform the following actions:
  • Copy the AEmail.dll (the ActiveEmail COM component) to a destination location on the new machine;
  • Register the COM component by using the following command: REGSVR32 <dest-location>\AEmail.dll
  • ONLY if you use queuing, make the proper registry setting as described below.

If you choose to install the Queue component manually on another machine, simply perform the following actions:
  • Copy the AEMailQ.exe (the ActiveEmail Queue Service) to a destination location on the new machine;
  • Install the service by giving the following command:INSTSVR <dest-location>\AEMailQ.exe.exe
  • Specify the Queue-directory in the registry:
        Key: HKEY_LOCAL_MACHINE\Software\ActiveXperts\ActiveEmail\PickupMailDir
        Data-type: REG_SZ
        Value: <a UNC path>
Queuing:
  • If you use queuing, ALL computers that you want to make use of the queue, must have the
      HKEY_LOCAL_MACHINE\Software\ActiveXperts\ActiveEmail\PickupMailDir
    value set. It must have the same value as the PickupMailDir value on the Queuing computer.



4. Using ActiveEmail

4.1. Introduction

The following code snippets (VBScript) illustrate how to use various ActiveEmail objects.


Send a simple e-mail message

   Set objSmtpServer          = CreateObject( "ActiveXperts.SmtpServer" ) ' Create SmtpServer object
   Set objSmtpMail            = CreateObject( "ActiveXperts.SmtpMail" )   ' Create SmtpMail object
   objSmtpServer.Connect( "smtp.mydomain.com" )                           ' Establish connection
   If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.FromAddress = "sender@mydomain.com"                     ' From (e-mail address)
      objSmtpMail.FromName    = "ActiveEmail Demo"                        ' From (name)
      objSmtpMail.Subject     = "ActiveEmail Message"
      objSmtpMail.Body        = "Hello, how are you?"
      objSmtpMail.AddTo "frank@myrecipients.com", "Frank"                 ' Add a recipient

     objSmtpServer.Send( objSmtpMail )                                    ' Send mail now
     objSmtpServer.Disconnect                                             ' Disconnect
   End If

Send an e-mail message: high priority, HTML formatted, to multiple recipients

   Set objSmtpServer          = CreateObject( "ActiveXperts.SmtpServer" ) ' Create SmtpServer object
   Set objSmtpMail            = CreateObject( "ActiveXperts.SmtpMail" )   ' Create SmtpMail object
   Set objConstants           = CreateObject( "ActiveXperts.EMailConstants" )  ' Create constants object
   objSmtpServer.Connect( "smtp.mydomain.com" )                           ' Establish connection
   If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.FromAddress = "sender@mydomain.com"                     ' From (e-mail address)
      objSmtpMail.FromName    = "ActiveEmail Demo"                        ' From (name)
      objSmtpMail.Subject     = "ActiveEmail Message"
      objSmtpMail.Priority    = objConstants.asMESSAGE_PRIORITY_HIGH      ' High priority
      objSmtpMail.BodyType    = objConstants.asMESSAGE_BODY_HTML          ' RTF/HTML body format)
      objSmtpMail.Body        = "<b>Hello, how are you?</b><br>I'm fine"
      objSmtpMail.AddTo  "frank@myrecipients.com", "Frank"                ' Add a recipient
      objSmtpMail.AddTo  "harry@myrecipients.com", "Harry"                ' Add a recipient
      objSmtpMail.AddCc  "joseph@myrecipients.com", "Joseph"              ' Add a CC recipient
      objSmtpMail.AddBcc "john@myrecipients.com", "John"                  ' Add a BCC recipient

     objSmtpServer.Send( objSmtpMail )                                    ' Send mail now
     objSmtpServer.Disconnect                                             ' Disconnect
   End If

Send an e-mail message with attachments

   Set objSmtpServer          = CreateObject( "ActiveXperts.SmtpServer" ) ' Create SmtpServer object
   Set objSmtpMail            = CreateObject( "ActiveXperts.SmtpMail" )   ' Create SmtpMail object
   objSmtpServer.Connect( "smtp.mydomain.com" )                           ' Establish connection
   If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.FromAddress = "sender@mydomain.com"                  
      objSmtpMail.FromName    = "ActiveEmail Demo"                     
      objSmtpMail.Subject     = "ActiveEmail Message"
      objSmtpMail.Body        = "Hello, how are you?"
      objSmtpMail.AddTo "frank@myrecipients.com", "Frank"              
      objSmtpMail.AddAttachment ".\picture1.jpg"                          ' Add attachment
      objSmtpMail.AddAttachment ".\picture2.jpg"                          ' Add anotherattachment

     objSmtpServer.Send( objSmtpMail )                                    ' Send mail now
     objSmtpServer.Disconnect                                             ' Disconnect
   End If

Receive e-mail headers

   Set objPop3Server = CreateObject ( "ActiveXperts.Pop3Server" )         ' Create Pop3Server object
   objPop3Server.Connect "pop3.mydomain.com", "acc", "passwd"             ' Connect to server, login using POP3 account 'acc'
   If( objPop3Server.LastError = 0 ) Then
      numMessages = objPop3Server.CountMessages()
      For i = 1 to numMessages                                            ' Iterate over all POP3 messages
         Set objPop3Mail = objPop3Server.GetEmailHeader( i )
         If ( objPop3Server.LastError = 0 ) Then
            WScript.Echo "MessageID        : " & objPop3Mail.ID
            WScript.Echo "   FromAddress   : " & objPop3Mail.FromAddress 
            WScript.Echo "   FromName      : " & objPop3Mail.FromName 
            WScript.Echo "   To            : " & objPop3Mail.ToAddress
            WScript.Echo "   Subject       : " & objPop3Mail.Subject
            WScript.Echo "   Date          : " & objPop3Mail.Date  
            WScript.Echo vbCrLf 
         End If
      Next
      objSmtpServer.Disconnect                                            ' Disconnect
   End If

Receive an e-mail

   Set objPop3Server   = CreateObject ( "ActiveXperts.Pop3Server" )       ' Create Pop3Server object
   objPop3Server.Connect "pop3.mydomain.com", "acc", "passwd"             ' Connect to server, login using POP3 account 'acc'
   If( objPop3Server.LastError = 0 ) Then

      numMessageID    = CInt( inputbox( "1", "Enter message ID (1 <= Message ID <= Count" )

      Set objPop3Mail = objPop3Server.GetEmail ( numMessageID )
      If( objPop3Server.LastError = 0 ) Then
         WScript.Echo "MessageID       : " & objPop3Mail.ID
         WScript.Echo "  From          : " & objPop3Mail.FromAddress
         WScript.Echo "  To            : " & objPop3Mail.ToAddress
         WScript.Echo "  Cc            : " & objPop3Mail.CcAddress
         WScript.Echo "  Reply Address : " & objPop3Mail.ReplyAddress	
         WScript.Echo "  Subject       : " & objPop3Mail.Subject
         WScript.Echo "  Priority      : " & objPop3Mail.Priority
         WScript.Echo "  Date          : " & objPop3Mail.Date
         WScript.Echo "  Hash          : " & objPop3Mail.Hash
         WScript.Echo "  Header        : " & Left ( objPop3Mail.Header, InStr ( objPop3Mail.Header, vbCrLf ) )	
         WScript.Echo "  Body          : " & Left ( objPop3Mail.Body, InStr ( objPop3Mail.Body, vbCrLf ) )
         WScript.Echo "  Attachments   : " & objPop3Mail.CountAttachments & vbCrLf
   
         numAttachments = objPop3Mail.CountAttachments 
         For i = 1 to numAttachments                                      ' Iterate over all attachments
           WScript.Echo "Attachment  : " & objPop3Mail.GetAttachment ( i )
         Next
      End If
      objSmtpServer.Disconnect                                            ' Disconnect
   End If

4.2. Visual Basic .NET

Make sure that the ActiveEmail Toolkit is installed on your system. For details about the installation, click here.

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

Declare and create a new Constants object in the following way:
   Dim objConstants As AEMAILLib.EMailConstants            ' Declaration
   objConstants = New AEMAILLib.EMailConstants()           ' Creation

Declare and create a new SmtpServer object in the following way:
   Dim objSmtpServer As AEMAILLib.SmtpServer               ' Declaration
   objSmtpServer = New AEMAILLib.SmtpServer()              ' Creation

Declare and create a new SmtpMail object in the following way:
   Dim objSmtpMail As AEMAILLib.SmtpMail                   ' Declaration
   objSmtpMail = New AEMAILLib.SmtpMail()                  ' Creation

Declare and create a new Pop3Server object in the following way:
   Dim objPop3Server As AEMAILLib.Pop3Server               ' Declaration
   objPop3Server = New AEMAILLib.Pop3Server()              ' Creation

Declare and create a new Pop3Mail object in the following way:
   Dim objPop3Mail As AEMAILLib.Pop3Mail                   ' Declaration
   objPop3Mail = New AEMAILLib.Pop3Mail()                  ' Creation

After declaration and creation of the object(s), you can use it in your Visual Basic .NET projects.
Visual Basic .NET samples are installed as part of the product, but can also be found on the ActiveXperts web site.

4.3. Visual C# .NET

Make sure that the ActiveEmail Toolkit is installed on your system. For details about the installation, click here.

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

Declare and create a new Constants object in the following way:
   using AEMAILLib;
   ...
   EmailConstants objConstants = new EmailConstants()      ' Declaration and Creation

Declare and create a new SmtpServer object in the following way:
   using AEMAILLib;
   ...
   SmtpServer objSmtpServer = new SmtpServer()             ' Declaration and Creation

Declare and create a new SmtpMail object in the following way:
   using AEMAILLib;
   ...
   SmtpMail objSmtpMail = new SmtpMail()                   ' Declaration and Creation

Declare and create a new Pop3Server object in the following way:
   using AEMAILLib;
   ...
   Pop3Server objPop3Server = new Pop3Server()             ' Declaration and Creation

Declare and create a new Pop3Mail object in the following way:
   using AEMAILLib;
   ...
   Pop3Mail objPop3Mail = new Pop3Mail()                   ' Declaration and Creation

After declaration and creation of the object(s), you can use it in your Visual C# .NET projects.
Visual C# .NET samples are installed as part of the product, but can also be found on the ActiveXperts web site.

4.4. Visual Basic

Make sure that the ActiveEmail Toolkit is installed on your system. For details about the installation, click here.

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

Declare and create a new Constants object in the following way:
   Dim objConstants As AEMAILLib.EmailConstants                      ' Declaration
   Set objConstants = CreateObject( "ActiveXperts.EmailConstants" )  ' Creation

Declare and create a new SmtpServer object in the following way:
   Dim objSmtpServer As AEMAILLib.SmtpServer                         ' Declaration
   Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )     ' Creation

Declare and create a new SmtpMail object in the following way:
   Dim objSmtpMail As AEMAILLib.SmtpMail                             ' Declaration
   Set objSmtpMail = CreateObject( "ActiveXperts.SmtpMail" )         ' Creation

Declare and create a new Pop3Server object in the following way:
   Dim objPop3Server As AEMAILLib.Pop3Server                         ' Declaration
   Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )     ' Creation

Declare and create a new Pop3Mail object in the following way:
   Dim objPop3Mail As AEMAILLib.Pop3Mail                             ' Declaration
   Set objPop3Mail = CreateObject( "ActiveXperts.Pop3Mail" )         ' Creation

Visual Basic samples are installed as part of the product, but can also be found on the ActiveXperts web site.

4.5. Visual C++

Make sure that the ActiveEmail Toolkit is installed on your system. For details about the installation, click here.
ActiveEmail can be used inside Visual C++ applications. Include the *.h and *.c file provided by ActiveXperts to bind your code to the ActiveEmail component.
These files are located in the Include directory of the Visual C++ samples directory. These are the files:
Declare and create a new Constants object in the following way:
   IEMailConstants *pConstants = NULL;                                    ' Declaration
   CoCreateInstance(CLSID_EMailConstants, NULL, CLSCTX_INPROC_SERVER, IID_IEMailConstants, (void**) &pConstants); 
                                                                          ' Creation

Declare and create a new SmtpServer object in the following way:
   ISmtpServer *pSmtpServer = NULL;                                       ' Declaration
   CoCreateInstance(CLSID_SmtpServer, NULL, CLSCTX_INPROC_SERVER, IID_ISmtpServer, (void**) &pSmtpServer);
                                                                          ' Creation

Declare and create a new SmtpMail object in the following way:
   ISmtpMail *pSmtpMail = NULL;                                           ' Declaration
   CoCreateInstance(CLSID_SmtpMail, NULL, CLSCTX_INPROC_SERVER, IID_ISmtpMail, (void**) &pSmtpMail); 
                                                                          ' Creation

Declare and create a new Pop3Server object in the following way:
   IPop3Server *pPop3Server = NULL;                                       ' Declaration
   CoCreateInstance(CLSID_Pop3Server, NULL, CLSCTX_INPROC_SERVER, IID_IPop3Server, (void**) &pPop3Server); 
                                                                          ' Creation

Declare and create a new Pop3Mail object in the following way:
   IPop3Mail *pPop3Mail = NULL;                                           ' Declaration
   CoCreateInstance(CLSID_Pop3Mail, NULL, CLSCTX_INPROC_SERVER, IID_IPop3Mail, (void**) &pPop3Mail); 
                                                                          ' Creation

Visual C++ samples are installed as part of the product, but can also be found on the ActiveXperts web site.

4.6. Delphi 6.x or higher

Make sure that ActiveEmail is installed on your system. For details about the installation, click here.

First, add a reference to the ActiveEmail objects:

You can create a new Constants object in the following way:
  EMailConstants : TConstants;                             ' Declaration of the wrapper class
  objConstants : IConstants;                               ' Declaration of the interface class
  objConstants := EMailConstants.DefaultInterface;         ' Creation new instance of the object
Declare and create a new SmtpServer object in the following way:
  SmtpServer : TSmtpServer;                                ' Declaration of the wrapper class
  objSmtpServer : ISmtpServer;                             ' Declaration of the interface class
  objSmtpServer := SmtpServer.DefaultInterface;            ' Creation new instance of the object
Declare and create a new SmtpMail object in the following way:
  SmtpMail : TSmtpMail;                                    ' Declaration of the wrapper class
  objSmtpMail : ISmtpMail;                                 ' Declaration of the interface class
  objSmtpMail := SmtpMail.DefaultInterface;                ' Creation new instance of the object
Declare and create a new Pop3Server object in the following way:
  Pop3Server : TPop3Server;                                ' Declaration of the wrapper class
  objPop3Server : IPop3Server;                             ' Declaration of the interface class
  objPop3Server := Pop3Server.DefaultInterface;            ' Creation new instance of the object
Declare and create a new Pop3Mail object in the following way:
  Pop3Mail : TPop3Mail;                                    ' Declaration of the wrapper class
  objPop3Mail : IPop3Mail;                                 ' Declaration of the interface class
  objPop3Mail := Pop3Mail.DefaultInterface;                ' Creation new instance of the object

4.7. ASP 2.x environment

   <html>
   <body>
   Version: 
   <script language=vbscript runat=server>
     Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )
     Response.Write objSmtpServer.Version
   </script>
   </body>
   </html>
Visual Basic .NET samples are installed as part of the product, but can also be found on the ActiveXperts web site.

A more convenient way of embedding server side scripting (ASP) is by putting the script code inside <% and %> delimiters:
   <html>
   <body>
   Version:
   <%
     Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer )
     Response.Write objSmtpServer.Version
   %>
   </body>
   </html>



5. Error Codes and Constants

 

5.1. Error Codes

When a function is called, the result of the function is stored in the object's 'LastError' property.
When 'LastError' is 0, it means that the last called function completed successfully; otherwise, an error occured.

The value of the LastError tells you why the function failed. All error codes are listed on the ActiveXperts web site:

www.activexperts.com/support/errorcodes (list of error codes).

Here, you can also lookup a specific error to find its description.

You can also call the 'GetErrorDescription' function of any of the objects to find the error description.
 

5.2. Constants

In ActiveEmail, all constants are grouped together in a separate object called EMailConstants. You must first create the Constants object before you can actually use constants:
   Set objConstants = CreateObject( "ActiveXperts.EMailConstants" )
   WScript.Echo objConstants.asMESSAGE_BODY_PLAIN
   WScript.Echo objConstants.asMESSAGE_BODY_HTML
   ...
 
5.2.1. Format Values

Name Description
asMESSAGE_BODY_PLAIN Plain message body (default)
asMESSAGE_BODY_HTML Message body supports HTML tags

 
5.2.2. Priority Values

Name Description
asMESSAGE_PRIORITY_HIGHEST Highest priority
asMESSAGE_PRIORITY_HIGH High priority
asMESSAGE_PRIORITY_MEDIUM Normal priority (default)
asMESSAGE_PRIORITY_LOW Low priority
asMESSAGE_PRIORITY_LOWEST Lowest priority

 
5.2.3. Encoding Values

Name Description
asMESSAGE_ENCODING_DEFAULT Default encoding. Uses the Operating System's current codepage
asMESSAGE_ENCODING_THAI ISO-8859-11 encoding
asMESSAGE_ENCODING_JAPANESE ISO-2022-jp encoding
asMESSAGE_ENCODING_CHINESE_SIMP GB2312 encoding
asMESSAGE_ENCODING_KOREAN KSC-5601 encoding
asMESSAGE_ENCODING_CHINESE_TRAD BIG5 encoding
asMESSAGE_ENCODING_CENTRALEUROPE ISO-8859-2 encoding
asMESSAGE_ENCODING_RUSSIAN ISO-8859-5 encoding
asMESSAGE_ENCODING_WESTERN ISO-8859-1 encoding
asMESSAGE_ENCODING_GREEK ISO-8859-7 encoding
asMESSAGE_ENCODING_TURKISH ISO-8859-3 encoding
asMESSAGE_ENCODING_HEBREW ISO-8859-8 encoding
asMESSAGE_ENCODING_ARABIC ISO-8859-6 encoding
asMESSAGE_ENCODING_BALTIC ISO-8859-4 encoding
asMESSAGE_ENCODING_VIETNAMESE WINDOWS-1258 encoding
asMESSAGE_ENCODING_UTF7 UTF-7 encoding
asMESSAGE_ENCODING_UTF8 UTF-8 encoding

 
5.2.4. SMTP Authentication Values

Name Description
asAUTH_SMTP_AUTO Auto detect (default)
asAUTH_SMTP_PLAIN AUTH-PLAIN authentication
asAUTH_SMTP_LOGIN AUTH-LOGIN authentication
asAUTH_SMTP_MD5CRAM AUTH-CRAM-MD5 authentication

 
5.2.5. POP3 Authentication Values

Name Description
asAUTH_POP3_AUTO Auto detect (default)
asAUTH_POP3_PLAIN AUTH-PLAIN authentication
asAUTH_POP3_APOP APOP authentication



6. SmtpServer Object

6.1. SmtpServer Object - Introduction

The SmtpServer object can be used to connect to an SMTP server and sumbit one or more SmtpMail messages.
By default, port 25 is used to connect to the remote SMTP server. You can also specify an alternate port.

The following sample demonstrates the use of the 'SmtpServer' object (sample written in VBScript).

Send a simple e-mail message

   Set objSmtpServer          = CreateObject( "ActiveXperts.SmtpServer" ) ' Create SmtpServer object
   Set objSmtpMail            = CreateObject( "ActiveXperts.SmtpMail" )   ' Create SmtpMail object
   objSmtpServer.Connect( "smtp.mydomain.com" )                           ' Establish connection
   If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.FromAddress = "sender@mydomain.com"                     ' From (e-mail address)
      objSmtpMail.FromName    = "ActiveEmail Demo"                        ' From (name)
      objSmtpMail.Subject     = "ActiveEmail Message"                     ' Subject
      objSmtpMail.Body        = "Hello, how are you?"                     ' Body
      objSmtpMail.AddTo "frank@myrecipients.com", "Frank"                 ' Add a recipient

     objSmtpServer.Send( objSmtpMail )                                    ' Send mail now
     objSmtpServer.Disconnect                                             ' Disconnect
   End If

6.2. SmtpServer Object - Overview of Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveEmail
ExpirationDate String Out n/a Expiration date of ActiveEmail
LogFile String In/Out n/a Log file, for troubleshooting purposes
HostPort Number In/Out Optional The TCP port of the SMTP server. Default: 25
Authentication Number In/Out Optional The preferred authentication mechanism
LastError String Out n/a Result of a previously called Send or Queue function
LastSmtpResponse String Out n/a Reponse of the SMTP server on last e-mail operation

Function Description
Activate Activate the product
Clear Clear all properties
Connect Connect to an SMTP server
Disconnect Disconnect SMTP session
IsConnected Get connection status
Send Send an e-mail message
GetErrorDescription Lookup error description of the given error code

6.3. SmtpServer Object - Properties


 SmtpServer::Version property

Description:
Version information of ActiveEmail. This property is read-only; you cannot assign a value to it.
Example:
    Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )        ' Create SmtpServer object
    ...
    WScript.Echo "Version: " & objSmtpServer.Version

 SmtpServer::ExpirationDate property

Description:
ExpirationDate of ActiveEmail. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.
Example:
    Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )        ' Create SmtpServer object
    ...
    WScript.Echo "ExpirationDate: " & objSmtpServer.ExpirationDate

 SmtpServer::LogFile property

Description:
For troubleshooting purposes, you can specify a log file to trace all SMTP operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all SMTP server operations will be written to this log file.
Example:
    Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )        ' Create SmtpServer object
    ...
    objSmtpServer.LogFile = "c:\smtp.log"                                ' Specify log file
    objSmtpServer.Connect( "smtp.mydomain.com" )
    If( objSmtpServer.LastError = 0 )
      ...
      objSmtpServer.Disconnect()
   End If

 SmtpServer::HostPort property

Description:
The 'HostPort' property specifies the port used by the Connect function to connect to a remote SMTP server. If the remote SMTP server uses a different port than port 25 (default), you can specify it by assigning a value to this property.
Example:
    Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )
    ...
    objSmtpServer.HostPort = 7025                  ' To specify an alternate port other than 25
    objSmtpServer.Connect( "smtp.myserver.com" )   ' Attempt to connect on port 7025
    ...

 SmtpServer::Authentication property

Description:
The 'Authentication' property specifies the mechanism used by the Connect function to authenticate to a remote SMTP server. By default, the ActiveEmail Toolkit uses auto-detection. For a list of valid authentication identifiers, click here.
NOTE: If you do not pass credentials to the Connect function (the 2nd and 3rd parameter of the function), the 'Authentication' property is ignored.
Example:
    Set objSmtpServer      = CreateObject( "ActiveXperts.SmtpServer" )
    Set objConstants       = CreateObject( "ActiveXperts.EMailConstants" )
    ...
    objSmtpServer.Authentication = objConstants.asAUTH_SMTP_MD5CRAM      
    objSmtpServer.Connect( "smtp.myserver.com", "userid", "passwd" )     ' Connect and authenticate using MD5/CRAM
    ...

 SmtpServer::LastError property

Description:
This read-only property indicates the result of the last called function. You should always checks the result of your functions. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
    Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )
    ...
    objSmtpServer.Send
    WScript.Echo "Result code: " & objSmtpServer.LastError
    WScript.Echo "Result description: " & objSmtpServer.GetErrorDescription( objSmtpServer.LastError )

 SmtpServer::LastSmtpResponse property

Description:
The last response of the SMTP server. The property is read-only; you cannot assign a value to it. The property can be very useful for troubleshooting purposes: when a mail fails, the information provided by the SMTP server can explain exactly what went wrong.

If you need more advanced trace information, try the LogFile property.
Example:
    Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )
    ...
    objSmtpServer.Send
    WScript.Echo "LastError: " & objSmtpServer.LastError
    WScript.Echo "Response of SMTP Server: " & objSmtp.LastSmtpResponse

6.4. SmtpServer Object - Functions


 SmtpServer::Activate function

Description:
This functions activates the ActiveEmail Toolkit product. A valid registration code should be passed as parameter.
Parameters:
  • The registration code
Return value:
Always 0. Check LastError property to see if the function completed successfully
Example:
    Set objSmtpServer  = CreateObject( "ActiveXperts.SmtpServer" )
    objSmtpServer.Activate "xxxxx-xxxxx-xxxxx"            ' replace xxxxx-xxxxx-xxxxx by your personal registration code

 SmtpServer::Clear function

Description:
This function clears all properties of the object.
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objSmtpServer = CreateObject( "ActiveXperts.SmtpServer" )
    objSmtpServer.Connect( "smtp.thisdomaindoesnotexist.com" )
    WScript.Echo objSmtpServer.LastError
    objSmtpServer.Clear()
    WScript.Echo objSmtpServer.LastError

 SmtpServer::Connect function

Description:
Connects to an SMTP server on port 25 (unless HostPort is set to a different port). After you've established a connection to the mail server, you can send one or more e-mail messages.
Call Disconnect to disconnect the session when you don't want to send any more messages.

There are a few different authentication mechanisms for SMTP. ActiveEmail auto-detects the way of authentication; if you want to force the toolkit to use a particular authentication mechanism, set the Authentication property before you call 'Connect'.
Parameters:
  • Host - Hostname or IP address of the mail server
  • Account (optional) - Only required if your SMTP server requires authentication
  • Password (optional) - Only required if your SMTP server requires authentication
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example (no authentication):
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    objSmtpServer.Connect( "smtp.domainname.com" )
    If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.From    = "me@mydomain.com"
      objSmtpMail.Subject = "This is my subject"
      ...
      objSmtpServer.Send
      objSmtpServer.Disconnect
    End If
Example (authentication required by SMTP server):
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    objSmtpServer.Connect( "exchange.domainname.com", "administrator", "mypassword" )
    If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.From    = "me@mydomain.com"
      objSmtpMail.Subject = "This is my subject"
      ...
      objSmtpServer.Send
      objSmtpServer.Disconnect
    End If

 SmtpServer::Disconnect function

Description:
After you've established a connection to the mail server, you can send one or more e-mail messages.
Call 'Disconnect' to disconnect the session.
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    objSmtpServer.Connect( "smtp.domainname.com" )
    If( objSmtpServer.LastError = 0 ) Then
      ...
      objSmtp.Disconnect
    End If

 SmtpServer::IsConnected function

Description:
This function returns True (-1) if the object has a connection to an SMTP server; otherwise, False (0) is returned.
Parameters:
None.
Return value:
True (-1) or False (0).
Example:
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    objSmtpServer.Connect( "smtp.domainname.com" )
    WScript.Echo objSmtpServer.LastError
    If( objSmtpServer.IsConnected() Then )
       WScript.Echo "Connected!"
    Else
       WScript.Echo "Not connected"
    End If
    ...

 SmtpServer::Send function

Description:
This function sends a SMTP message directly to a SMTP server. You must first establish a connection to your mail server before you can call the 'Send' function.
Parameters:
  • Host - Hostname or IP address of the mail server
  • SmtpMail object - You must pass an SmtpMail object with all mandatory fields set (i.e.. at least one recipient and a sender address).
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    objSmtpServer.Connect( "smtp.domainname.com" )
    If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.From    = "me@mydomain.com"
      objSmtpMail.AddTo "john@company.com", "My Friend John"
      objSmtpMail.Subject = "This is my subject"
 	 ...
      objSmtpServer.Send( objSmtpMail )
      objSmtpServer.Disconnect
    End If

 SmtpServer::Queue function

Description:
This function puts an SMTP message into the queue. The ActiveEmail Queue Service will pick it up and send it to the SMTP server.
You do NOT need to establish a conection to the mail server first (this is done by the ActiveEmail Queue Server service).
Parameters:
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    ...
    objSmtpMail.From    = "me@mydomain.com"
    objSmtpMail.AddTo "john@company.com", "My Friend John"
    objSmtpMail.Subject = "This is my subject"
    ...
    objSmtpServer.Queue( "smtp.domainname.com", objSmtpMail )

 SmtpServer::GetErrorDescription function

Description:
Function to retrieve the explanation of an error code.
Parameters:
  • Error Code.
Return value:
The Error string.
Example:
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    objSmtpServer.Connect( "smtp.domainname.com" )
    If( objSmtpServer.LastError = 0 ) Then
      ...
      objSmtpServer.Disconnect
    Else
      WScript.Echo "Error description: " & objSmtpServer.GetErrorDescription( objSmtpServer.LastError )
    End If



7. SmtpMail Object

7.1. SmtpMail Object - Introduction

The SmtpMail object holds all properties of an SMTP message, like: recipients, subject, body, priority, attachments, etc.. The SmtpMail object can be used by SmtpServer's Send and Queue functions, where the SmtpMail object is passed as parameter.

The following sample demonstrates the use of the 'SmtpMail' object (sample written in VBScript).

Use SmtpMail object to send an e-mail

    ' Create a new SmtpMail object; assign values to properties
    Set objSmtpMail         = CreateObject( "ActiveXperts.SmtpMail" )   
    objSmtpMail.FromAddress = "sender@mydomain.com"                     ' From (e-mail address)
    objSmtpMail.FromName    = "ActiveEmail Demo"                        ' From (name)
    objSmtpMail.Subject     = "ActiveEmail Message"                     ' Subject
    objSmtpMail.Body        = "Hello, how are you?"                     ' Body
    objSmtpMail.AddTo "frank@myrecipients.com", "Frank"                 ' Add a recipient
 
    ' Create a new SmtpServer object; connect to the mail server
    Set objSmtpServer       = CreateObject( "ActiveXperts.SmtpServer" ) ' Create SmtpServer object
    objSmtpServer.Connect( "smtp.mydomain.com" )                        ' Establish connection
    If( objSmtpServer.LastError <> 0 ) Then
       WScript.Quit
    End If
 
    ' Send the message
    objSmtpServer.Send( objSmtpMail )                                   ' Send mail now
 
    objSmtpServer.Disconnect                                            ' Disconnect

7.2. SmtpMail Object - Overview of Properties and Functions

Property Type In/Out Mand/Opt Description
FromAddress String In/Out Optional The Sender's e-mail address
FromName String In/Out Optional The Sender's name
Organization String In/Out Optional The Sender's organization name
ReplyAddress String In/Out Optional The Sender's reply-address. If not specified, FromAddress will be the reply-address
ReadReceiptAddress String In/Out Optional E-mail address of the person who should receive read receipt(s) of the outgoing e-mail
Encoding Number In/Out Optional The encoding to be used. Various encodings are supported, including: Japanese, Chinese, Russian, Greek, Turkish and more
Subject String In/Out Optional The Subject of the message
Priority Number In/Out Optional The Priority of the message. There a five different priority-levels
BodyType Number In/Out Optional The Body type of the message.
Body String In/Out Optional The Body of the message
LastError String Out n/a Result of a previously called function

Function Description
Clear Clear all properties
AddTo Add an e-mail recipient
AddCc Add a Carbon Copy Recipient (CC)
AddBcc Add a Blind Carbon Copy Recipient (BCC)
AddAttachment Add an attachment
LoadMIME Load properties, recipients and attachments from a MIME file
SaveMIME Save properties, recipients and attachments to a MIME file

7.3. SmtpMail Object - Properties


 SmtpMail::FromAddress and FromName properties

Description:
The FromAddress and FromName fields specify the Sender. The FromAddress specifies the Sender's e-mail address. This is the return-path for your e-mail, unless you specify the ReplyAddress property. The ReplyAddress property always overrides the FromAddress property for it's return path. The FromName field specifies the sender's friendly name.
You can only declare one sender.
FromAddress and FromName are optional properties, because RFC 822 doesn't require a sender specification for e-mail transmissions.
Example:
    Set objSmtpMail = CreateObject( "ActiveXperts.SmtpMail" )
    ...
    objSmtpMail.From     = "me@mydomain.doc"
    objSmtpMail.FromName = "This is Me"
    ...

 SmtpMail::Organization property

Description:
The sender's organization name.
Example:
    Set objSmtpMail = CreateObject( "ActiveXperts.SmtpMail" )
    ...
    objSmtpMail.Organization = "My Organization"

 SmtpMail::ReplyAddress property

Description:
The Reply-address of the e-mail. If not specified, the reply-address will be the address indicated by the FromAddress property.
Example:
    Set objSmtpMail = CreateObject( "ActiveXperts.SmtpMail" )
    ...
    objSmtpMail.ReplyAddress = "myself@mydomain.com"

 SmtpMail::ReadReceiptAddress property

Description:
E-mail 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 objSmtpMail = CreateObject( "ActiveXperts.SmtpMail" )
    ...
    objSmtpMail.ReadReceiptAddress = "myself@mydomain.com"

 SmtpMail::Encoding property

Description:
For a list of valid encoding values, click here.

Example:
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    Set objConstants      = CreateObject( "ActiveXperts.EMailConstants" )
    ...
    objSmtpMail.Encoding  = objConstants.asMESSAGE_ENCODING_JAPANESE     ' Message will be encoded as Japanese text

 SmtpMail::Subject property

Description:
The Subject of a message. Not mandatory.
Example:
   Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
   ...
   objSmtpMail.Subject   = "This is an important message"

 SmtpMail::Priority property

Description:
The Priority of the message. There are 5 priority levels, described here.
Example:
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    Set objConstants      = CreateObject( "ActiveXperts.EMailConstants" )
   ...
    objSmtpMail.Priority  = objConstants.asPRIORITYHIGH                  ' High priority

 SmtpMail::BodyType , SmtpMail::Body properties

Description:
Two body formats are supported by ActiveEmail
  • Clear Text format (default);
  • Rich Text Format (HTML format).

A message body in Plain Text format doesn't support any formatting capabilities; it doesn't support embedded objects either.
A message body in HTML format supports HTML text formatting tags, as well as embedded objects like images and sounds.

There are two values for the BodyType:
If you send a Plain Text message, you can include newlines by including vbCrLf characters inside you message.

If you send a HTML message, you can embed an object inside the message. The object must be added as an attachment (see also: AddAttachment).
Every attachment has a unique identifier. The first attachment has identier 000001, the second one has 000002, etc.
To embed an attached object, you must refer to the object from within the message body. This referal can be made in the following way:
   <img SRC="cid:0000001" >
Example: Clear Text formatted body
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    ...
    ' Default body format: plain text, so no need to change objSmtpMail.BodyType
    objSmtpMail.Body      = "This is my body message." & vbCrLf & "Best regards."
Example: HTML formatted body
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    Set objConstants      = CreateObject( "ActiveXperts.EMailConstants" )  ' Create constants object
    ...
    objSmtpMail.BodyType  = objConstants.asMESSAGE_BODY_HTML
    objSmtpMail.Body      = "<html><body>This is my <i>body message</i>.<br>Regards.</body></html>"
Example: HTML formatted body with to embedded objects
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    Set objConstants      = CreateObject( "ActiveXperts.EMailConstants" )  ' Create constants object
    ...
    objSmtpMail.AddAttachment "C:\MySelf.jpg"
    objSmtpMail.AddAttachment "C:\MyWife.jpg"
    objSmtpMail.BodyType  = objConstants.asMESSAGE_BODY_HTML
    objSmtpMail.Body      = "<html><body>This <SRC="01"> is me <br>and <SRC="02" my wife<br></body></html>

 SmtpMail::LastError property

Description:
This read-only property indicates the result of the last called function. You should always checks the result of your functions. 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( "ActiveXperts.SmtpMail" )
    ...
    objSmtpMail.AddAttachment( "C:\File.txt" )
    WScript.Echo "Result code: " & objSmtpMail.LastError

7.4. SmtpMail Object - Functions


 SmtpMail::Clear function

Description:
This function clears all properties of the object. If you send multiple messages in a row, it is recommended to call this function after each call of Send or Queue.
Parameters:
None.
Return value:
Always 0.
Example:
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" ) ' Create SmtpServer object
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    objSmtpServer.Connect( "smtp.domainname.com" )
    If( objSmtpServer.LastError = 0 ) Then
      objSmtpMail.From    = "me@mydomain.com"
      objSmtpMail.AddTo "john@company.com", "My Friend John"
      objSmtpMail.Subject = "This is my subject"
      objSmtpMail.Body = "This is my message to you"
      objSmtpServer.Send( objSmtpMail )
      objSmtpMail.Clear                                               ' Clear mail properties
      objSmtpMail.From    = "me@mydomain.com"
      objSmtpMail.AddTo "michael@company.com", "My Friend Michael"
      objSmtpMail.Subject = "This is my subject"
      objSmtpMail.Body = "This is my message to you"
      objSmtpServer.Send( objSmtpMail )
      objSmtpServer.Disconnect
    End If

 SmtpMail::AddTo, SmtpMail::AddCC and SmtpMail::AddBcc, functions

Description:
Use AddTo to add a normal recipient, use AddCc to add a Carbon Copy recipient, and use AddBcc to add a Blind Carbon Copy recipient.
All three functions can be called multiple times, to add multiple recipients.
Parameters:
  • The e-mail address of the recipient;
  • The friendly name of the recipient (empty string allowed).
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    objSmtpMail.AddTo "roger@thecompany.com", "My friend Roger"
    objSmtpMail.AddTo "mike@thecompany.com", ""
 
    objSmtpMail.AddCc "dennis@thecompany.com", "My friend Dennis"
 
    objSmtpMail.AddBcc "jim@thecompany.com", ""
    objSmtpMail.AddBcc "joe@thecompany.com", "My friend Joe"

 SmtpMail::AddAttachment function

Description:
This function allows you to add one or more file attachment. These attachments can be either ASCII or binary format.
Every attachment has its own unique internal ID. You can use this ID to embed the attachment inside a Body message.
Parameters:
  • The file attachment.
Return value:
Always 0. If you specify an invalid attachment, the Send function will fail.
Example:
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    objSmtpMail.AddAttachment "c:\temp\mypicture.jpg"
    objSmtpMail.AddAttachment "c:\temp\mydocument.doc"

 SmtpMail::LoadMIME function

Description:
This function loads all properties, recipients and attachments from a MIME file. This can be a MIME file that was created by the SaveMIME function, or by another e-mail client including Microsoft Outlook Express and Microsoft Mail.
Parameters:
  • The MIME file.
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    Set objSmtpServer     = CreateObject( "ActiveXperts.SmtpServer" )
    objSmtpMail.LoadMIME( "C:\File.mim" )
    WScript.Echo "LoadMIME, result: " & objSmtpMail.LastError
    ...
    objSmtpServer.Connect( "mailserver.company.intra" )
    objSmtpServer.Send( objSmtpMail )
    objSmtpServer.Disconnect()

 SmtpMail::SaveMIME function

Description:
This function saves all properties, recipients and attachments to a MIME file. This MIME file can be used at any time by the LoadMIME function, or by another e-mail client including Microsoft Outlook Express and Microsoft Mail.
Parameters:
  • The MIME file.
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objSmtpMail       = CreateObject( "ActiveXperts.SmtpMail" )
    objSmtpMail.From      = "me@mydomain.com"
    objSmtpMail.AddTo "john@company.com", "My Friend John"
    objSmtpMail.Subject   = "This is my subject"
    objSmtpMail.Body      = "This is my message to you"
    objSmtpMail.AddAttachment "c:\temp\mypicture.jpg"
    objSmtpMail.AddAttachment "c:\temp\mydocument.doc"
    objSmtpMail.SaveMIME( "C:\File.mim" )
    WScript.Echo "SaveMIME, result: " & objSmtpMail.LastError



8. Pop3Server Object

8.1. Pop3Server Object - Introduction

The Pop3Server object can be used to connect to an POP3 server and sumbit one or more Pop3Mail messages.
By default, port 25 is used to connect to the remote POP3 server. You can also specify an alternate port.

The following sample demonstrates the use of the 'Pop3Server' object (sample written in VBScript).


Show the first 3 messages in a mailbox

    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )        ' Create Pop3Server object
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )     ' Connect to the POP3 server, and login using
                                                                         ' account 'userid', password 'passwd'
    If( objPop3Server.LastError = 0 ) Then 
       numMessages = objPop3Server.CountMessages()                       ' Count the messages in the mailbox
       WScript.Echo numMessages & " new message(s) in mailbox."
       For i = 1 to 3                                                    ' Iterate over the first 3 messages in the mailbox
          Set objPop3Mail = objPop3Server.GetEmail( i )                  ' Get e-mail
          If ( objPop3Server.LastError = 0 ) Then                        ' If message does exist then show details
 
             WScript.Echo "MessageID       : " & objPop3Mail.ID          ' Show e-mail information
             WScript.Echo "  Size          : " & objPop3Mail.Size
             WScript.Echo "  FromAddress   : " & objPop3Mail.FromAddress
             WScript.Echo "  FromName      : " & objPop3Mail.FromName
             WScript.Echo "  Organization  : " & objPop3Mail.Organization
             WScript.Echo "  Reply Address : " & objPop3Mail.ReplyAddress	
             WScript.Echo "  Read Receipt Address : " & objPop3Mail.ReadReceiptAddress	
             WScript.Echo "  ToAddress     : " & objPop3Mail.ToAddress
             WScript.Echo "  CcAddress     : " & objPop3Mail.CcAddress
             WScript.Echo "  Priority      : " & objPop3Mail.Priority
             WScript.Echo "  Date          : " & objPop3Mail.Date
             WScript.Echo "  Subject       : " & objPop3Mail.Subject
             WScript.Echo "  BodyType      : " & objPop3Mail.BodyType
             WScript.Echo "  Body          : " & Left ( objPop3Mail.Body, InStr ( objPop3Mail.Body, vbCrLf ) )
             WScript.Echo "  Attachments   : " & objPop3Mail.CountAttachments & vbCrLf
    
             numAttachments = objPop3Mail.CountAttachments 
             For i = 1 to numAttachments                                 ' Iterate over all attachments
                WScript.Echo "Attachment Name : " & objPop3Mail.GetAttachmentName(i)
                WScript.Echo "Attachment Size : " & objPop3Mail.GetAttachmentSize(i)
 
                ' NOTE: attachments can be saved using the 'SaveAttachment' function
             Next
          End If
       Next
       objPop3Server.Disconnect                                          ' Disconnect
    End If

List all e-mail headers of a mailbox

    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )        ' Create Pop3Server object
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )     ' Connect to the POP3 server, and login using
                                                                         ' account 'userid', password 'passwd'
    If( objPop3Server.LastError = 0 ) Then 
       numMessages = objPop3Server.CountMessages()                       ' Count the messages in the mailbox
       WScript.Echo numMessages & " new message(s) in mailbox."
       For i = 1 to numMessages                                          ' Iterate over all messages in the mailbox
          Set objPop3Mail = objPop3Server.GetEmailHeader( i )            ' Get the header of the particular e-mail
          If ( objPop3Server.LastError = 0 ) Then                        
             WScript.Echo "MessageID       : " & objPop3Mail.ID          ' Show header information
             WScript.Echo "  Size          : " & objPop3Mail.Size
             WScript.Echo "  FromAddress   : " & objPop3Mail.FromAddress
             WScript.Echo "  FromName      : " & objPop3Mail.FromName
             WScript.Echo "  Organization  : " & objPop3Mail.Organization
             WScript.Echo "  Reply Address : " & objPop3Mail.ReplyAddress	
             WScript.Echo "  Read Receipt Address : " & objPop3Mail.ReadReceiptAddress	
             WScript.Echo "  ToAddress     : " & objPop3Mail.ToAddress
             WScript.Echo "  CcAddress     : " & objPop3Mail.CcAddress
             WScript.Echo "  Priority      : " & objPop3Mail.Priority
             WScript.Echo "  Date          : " & objPop3Mail.Date
             WScript.Echo "  Subject       : " & objPop3Mail.Subject
             WScript.Echo "  BodyType      : " & objPop3Mail.BodyType
 
             ' To retrieve the Body and the Attachments, use 'GetEmailMessage'
          End If
       Next
       objPop3Server.Disconnect                                          ' Disconnect
    End If

8.2. Pop3Server Object - Overview of Properties and Functions

Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveEmail
ExpirationDate String Out n/a Expiration date of ActiveEmail
LogFile String In/Out n/a Log file, for troubleshooting purposes
HostPort Number In/Out Optional The TCP port of the POP3 server. Default: 110
Authentication Number In/Out Optional The preferred authentication mechanism
Timeout Number In/Out Optional The timeout used when retrieving data
LastError String Out n/a Result of a previously called function
LastPop3Response String Out n/a Reponse of the POP3 server on the last operation

Function Description
Activate Activate the product
Clear Clear all properties
Connect Connect to a POP3 server
Disconnect Disconnect POP3 session
IsConnected Get connection status
CountMessages Count messages in the current mailbox
GetEmailHeader Get the header of a specific message in the mailbox
GetEmailMessage Get the e-mail
DeleteMessage Delete a specific message from the mailbox
GetErrorDescription Lookup error description of the given error code

8.3. Pop3Server Object - Properties


 Pop3Server::Version property

Description:
Version information of ActiveEmail. This property is read-only; you cannot assign a value to it.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )        ' Create Pop3Server object
    ...
    WScript.Echo "Version: " & objPop3Server.Version

 Pop3Server::ExpirationDate property

Description:
ExpirationDate of ActiveEmail. This property is read-only; you cannot assign a value to it. Once you have registered the product, the property holds the empty string ("") value.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )        ' Create Pop3Server object
    ...
    WScript.Echo "ExpirationDate: " & objPop3Server.ExpirationDate

 Pop3Server::LogFile property

Description:
For troubleshooting purposes, you can specify a log file to trace all POP3 operations. By default, the 'LogFile' property holds the empty string. By assigning a valid filename to it, all POP3 server operations will be written to this log file.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )        ' Create Pop3Server object
    ...
    objPop3Server.LogFile = "c:\smtp.log"                                ' Specify log file
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )
    If( objPop3Server.LastError = 0 )
      ...
      objPop3Server.Disconnect()
   End If

 Pop3Server::HostPort property

Description:
The 'HostPort' property specifies the port used by the Connect function to connect to a remote POP3 server. If the remote POP3 server uses a different port than port 110 (default), you can specify it by assigning a value to this property.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )
    ...
    objPop3Server.HostPort = 8110                                        ' To specify an alternate port other than 110
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )     ' Attempt to connect on port 8110
    ...

 Pop3Server::Authentication property

Description:
The 'Authentication' property specifies the mechanism used by the Connect function to authenticate to a remote POP3 server. By default, the ActiveEmail Toolkit uses auto-detection. For a list of valid authentication identifiers, click here.
Example:
    Set objPop3Server      = CreateObject( "ActiveXperts.Pop3Server" )
    Set objConstants       = CreateObject( "ActiveXperts.EMailConstants" )
    ...
    objPop3Server.Authentication = objConstants.asAUTH_POP3_APOP      
    objPop3Server.Connect( "pop3.myserver.com", "userid", "passwd" )     ' Connect and authenticate using APOP
    ...

 Pop3Server::Timeout property

Description:
The 'Timeout' property indicates the timeout used when retrieving data, in seconds. Default: 60 seconds. This property should suffice in most circumstances. Please note that a virus scanner will first dowload and check the body and attachment database before it will actually delivered the data to ActiveEmail. With a slow internet connection, you may need to increase the 'Timeout' property.
Example:
    Set objPop3Server      = CreateObject( "ActiveXperts.Pop3Server" )
    ...
    objPop3Server.Timeout = 300                                          ' Use a timeout of 5 minutes
    ...

 Pop3Server::LastError property

Description:
This read-only property indicates the result of the last called function. You should always checks the result of your functions. A zero indicates: success. Any non-zero value means an error.
The GetErrorDescription function provides the error description of an error code.
For a complete list of error codes, check out the following page: www.activexperts.com/support/errorcodes.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )
    ...
    objPop3Server.GetEmailHeader( 1 )
    WScript.Echo "Result code: " & objPop3Server.LastError
    WScript.Echo "Result description: " & objPop3Server.GetErrorDescription( objPop3Server.LastError )

 Pop3Server::LastPop3Response property

Description:
The last response of the POP3 server. The property is read-only; you cannot assign a value to it. The property can be very useful for troubleshooting purposes.

If you need more advanced trace information, try the LogFile property.
Example:
   Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )
   ...
   objPop3Server.GetEmailHeader( 1 )
   WScript.Echo "Result code: " & objPop3Server.LastError
   WScript.Echo "Last POP3 response: " & objPop3Server.LastPop3Response

8.4. Pop3Server Object - Functions


 Pop3Server::Activate function

Description:
This functions activates the ActiveEmail Toolkit product. A valid registration code should be passed as parameter.
Parameters:
  • The registration code.
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objPop3Server  = CreateObject( "ActiveXperts.Pop3Server" )
    objPop3Server.Activate "xxxxx-xxxxx-xxxxx"                           ' replace xxxxx-xxxxx-xxxxx by your personal registration code

 Pop3Server::Clear function

Description:
This function clears all properties of the object.
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )
    WScript.Echo objPop3Server.LastError
    objPop3Server.Clear()
    WScript.Echo objPop3Server.LastError

 Pop3Server::Connect function

Description:
Connect to an POP3 server on port 110 (unless HostPort is set to a different port) and open a mailbox. After you've established a connection to the mail server, you can receive e-mail messages.
Call Disconnect to disconnect the session after you finished receiving the messages.

A POP3 mailbox requires authentication, so you must specify an user-id and a password as additional parameters.
There are a few different authentication mechanisms for POP3. ActiveEmail auto-detects the way of authentication; if you want to force the toolkit to use a particular authentication mechanism, set the Authentication property before you call 'Connect'.
Parameters:
  • Host - Hostname or IP address of the POP3 server
  • User ID - User ID of the mailbox you want to open
  • Password - Password of the mailbox
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example (no authentication):
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )     ' Connect to the POP3 server, and login using
                                                                         ' account 'userid', password 'passwd'
    If( objPop3Server.LastError = 0 ) Then 
       numMessages = objPop3Server.CountMessages()                       ' Count the messages in the mailbox
       WScript.Echo numMessages & " new message(s) in mailbox."
       objPop3Server.Disconnect                                          ' Disconnect
    End If                                                               

 Pop3Server::Disconnect function

Description:
After you've established a connection to the POP3 server, you can receive e-mail messages.
Call 'Disconnect' to disconnect the session.
Parameters:
None.
Return value:
Always 0. Check LastError property to see if the function completed successfully.
Example:
    Set objPop3Server     = CreateObject( "ActiveXperts.Pop3Server" )
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )     
    If( objPop3Server.LastError = 0 ) Then
      ...
      objPop3.Disconnect                                                 ' Disconnect
    End If

 Pop3Server::IsConnected function

Description:
This function returns True (-1) if the object has a connection to a POP3 server; otherwise, False (0) is returned.
Parameters:
None.
Return value:
True (-1) or False (0).
Example:
    Set objPop3Server     = CreateObject( "ActiveXperts.Pop3Server" )
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )
    WScript.Echo objPop3Server.LastError
    If( objPop3Server.IsConnected() Then )
       WScript.Echo "Connected!"
    Else
       WScript.Echo "Not connected"
    End If
    ...

 Pop3Server::CountMessages function

Description:
This function counts the number of messages in the current mailbox. You must first call the Connect function to open a mailbox on the POP3 server.
Parameters:
None.
Return value:
The number of messages in the mailbox. If the function fails, 0 is returned and the LastError is set.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )     
                                                                         
    If( objPop3Server.LastError = 0 ) Then 
       numMessages = objPop3Server.CountMessages()                       ' Count the messages in the mailbox
       WScript.Echo numMessages & " new message(s) in mailbox."
       objPop3Server.Disconnect                                          
    End If                                                               

 Pop3Server::GetEmailHeader function

Description:
This function retrieves the header of the e-mail. If the function completes successfully, a Pop3Mail object is returned with all properties filled except the body and the attachments.
You must first call the Connect function to open a mailbox on the POP3 server.
Parameters:
  • Message ID. This ID must be greater or equal to 1 and less or equal than CountMessages().
Return value:
A new Pop3Mail object (or NULL if the function fails). Check LastError property to see if the function completed successfully.
Example:
    Set objPop3Server = CreateObject( "ActiveXperts.Pop3Server" )
    objPop3Server.Connect( "pop3.mydomain.com", "userid", "passwd" )
    If( objPop3Server.LastError = 0 ) Then
       If( objPop3Server.CountMessages() > 0 ) Then
          Set objPop3Mail = objPop3Server.GetEmailHeader( 1 )            ' Get header of the e-mail (ID:1)
          If ( objPop3Server.LastError = 0 ) Then                        
             WScript.Echo "MessageID       : " & objPop3Mail.ID          ' Show header information
             WScript.Echo "  Size          : " & objPop3Mail.Size
             WScript.Echo "  FromAddress   : " & objPop3Mail.FromAddress
             WScript.Echo "  FromName      : " & objPop3Mail.FromName
             WScript.Echo "  Organization  : " & objPop3Mail.Organization
             WScript.Echo "  Reply Address : " & objPop3Mail.ReplyAddress	
             WScript.Echo "  Read Receipt Address : " & objPop3Mail.ReadReceiptAddress	
             WScript.Echo "  ToAddress     : " & objPop3Mail.ToAddress
             WScript.Echo "  CcAddress     : " & objPop3Mail.CcAddress
             WScript.Echo "  Priority      : " & objPop3Mail.Priority
             WScript.Echo "  Date          : " & objPop3Mail.Date
             WScript.Echo "  Subject       : " & objPop3Mail.Subject
             WScript.Echo "  BodyType      : " & objPop3Mail.BodyType