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, IMAP 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 IMAP and POP3;
  • Embedded objects in message body, like sounds, images, etc.;
  • Connect to secure server using TLS / SSL
  • Full Unicode support in all protocols (IMAP, POP3, SMTP)
  • SMTP authorization, supporting AUTH PLAIN, AUTH LOGIN and AUTH CRAM-MD5 login algorithms;
  • POP3 authorization, supporting Plain text and APOP3 authorization;
  • IMAP authorization, supporting Plain text and LOGIN 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 R2 (64-bit)
  • Windows Server 2012 (64-bit)
  • Windows Server 2008 R2 (64-bit)
  • Windows Server 2008 (32-bit and 64-bit)
  • Windows Server 2003 (32-bit and 64-bit)
  • Windows 10 (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 Read/Write 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.

By default the log file uses the UTF16LE character encoding. To use UTF8 please prefix the log file name with the text: 'UTF8:' (e.g.: 'UTF8:logfile.txt').

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 Read/Write 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.

By default the log file uses the UTF16LE character encoding. To use UTF8 please prefix the log file name with the text: 'UTF8:' (e.g.: 'UTF8:logfile.txt').

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. Imap

7.1. Introduction

The Internet Message Action Protocol (IMAP) is a standard and much used protocol to retrieve email messages and manage mailboxes that exist on a remote server. This Imap object is a quick and easy way to access IMAP servers.

Normally IMAP refers to IMAP4rev1. This is the most used version of the standard and is fully supported by this component.

This is an example that quickly connects and retrieves any unseen emails from the default mailbox on the server:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.SetSecure
  objImap.Connect "imap.gmail.com", "username", "password"
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
 
  objImap.Select "INBOX"
  Set objEmail = objImap.FetchFirstEmail(objConstants.IMAP_SK_UNSEEN)
  While objImap.LastError = 0
    
    WScript.Echo "MessageID        : " & objEmail.ImapUID
    WScript.Echo "   From          : " & objEmail.FromAddress
    WScript.Echo "   From Name     : " & objEmail.FromName
    WScript.Echo "   To            : " & objEmail.ToAddress
    WScript.Echo "   Subject       : " & objEmail.Subject
    WScript.Echo "   Date          : " & objEmail.Date  
    WScript.Echo vbCrLf 
  
    Set objEmail = objImap.FetchNextEmail
  WEnd
  
  objImap.Disconnect

This is an example that lists all mailboxes in the root of the mail account on the mail server:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.SetSecure
  objImap.Connect "imap.gmail.com", "username", "password"
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
 
  objImap.List "", "%"
  WScript.Echo "List, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  WScript.Echo
  
  nCount = objImap.ListCount
  WScript.Echo "Found " & objImap.ListCount & " mailboxes:"
  If nCount > 0 Then
    For i = 0 To nCount - 1
      strMailboxName = objImap.ListName(i)
      strMailboxAttributes = objImap.ListAttributes(i)
      
      WScript.Echo "  "  & strMailboxName & ": " & strMailboxAttributes
    Next
  End If
  
  objImap.Disconnect

7.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 Read/Write 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 Port number to connect to
Authentication Number Read/Write Preferred authentication method
UseStartTls Boolean Read/Write Use STARTTLS capability when available
AutoClose Boolean Read/Write Automatically close the mailbox before disconnect
IpVersion Number Read/Write IP Version to use (IPv4 or IPv6)
Secure Number Read/Write Enable secure connect
LastImapResponse String Read Last response text from server
HierarchySeparator String Read Path separator used by server
Capabilities String Read List of server capabilities
Exists Number Read Number of messages in the selected mailbox
Recent Number Read Number of 'Recent' messages in the selected mailbox
Unseen Number Read Number of 'Unseen' messages in the selected mailbox
UidNext Number Read Next UID the server is going to use
TimeoutConnect Number Read/Write Timeout while connecting in milliseconds
TimeoutCommand Number Read/Write Command timeout for any command in milliseconds
TimeoutAppend Number Read/Write Timeout while appending a new email to a mailbox in milliseconds
FetchMaxNumItemsAtOnce Number Read/Write Maximum number of items to fetch at once
MaximumPendingFetchData Number Read/Write Maximum number of pending fetch items
MaximumPendingExpunged Number Read/Write Maximum number of pending expunged notifications
UseSequenceNumForStoreAndCopy Boolean Read/Write Use sequence number instead of UID for store and copy

Version property

Return the version number of the ActiveXperts Email Component

Example:

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

Build property

Return the build number of the ActiveXperts Email Component.

Example:

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

Module property

Return the module name of the ActiveXperts Email Component.

Example:

Set objImap = CreateObject("AxEmail.Imap")
Wscript.Echo "ActiveXperts Email Component Version"  & objImap.Version & "; Build"  & _
  objImap.Build & "; Module"  & objImap.Module
WScript.Echo "License Status:"  & objImap.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 objImap = CreateObject("AxEmail.Imap")                 ' Create new instance
WScript.Echo "License Status:"  & objImap.LicenseStatus
WScript.Echo "License Key:"  & objImap.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 objImap = CreateObject("AxEmail.Imap")                 ' Create new instance
objImap.LicenseKey = "XXXXX-XXXXX-XXXXX"                ' Assign your license key 
WScript.Echo "LicenseKey:"  & objImap.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 objImap = CreateObject("AxEmail.Imap")
objImap.Connect "imap.example.com", "me@example.com", "password"
If objImap.LastError <> 0 Then
  WScript.Echo "Error:"  & objImap.GetErrorDescription(objImap.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.

By default the log file uses the UTF16LE character encoding. To use UTF8 please prefix the log file name with the text: 'UTF8:' (e.g.: 'UTF8:logfile.txt').

Example:

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

HostPort property

The port number on the server to connect to.

This is set to 143 by default and set to 993 after calling SetSecure. Use this property when the IMAP server is configured on a different port number.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.HostPort = 993
  objImap.Secure = True
  objImap.Authentication = objConstants.IMAP_AUTH_AUTO
  objImap.Connect strServer, strServerAccount, strServerPassword 
  
  ' ...  
  
  objImap.Disconnect 

Authentication property

Preferred authentication method to use when logging into the IMAP server. Find the possible options here. By default this is set to 'auto'.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.HostPort = 993
  objImap.Secure = True
  objImap.Authentication = objConstants.IMAP_AUTH_AUTO
  objImap.Connect strServer, strServerAccount, strServerPassword 
  
  ' ...  
  
  objImap.Disconnect 

UseStartTls property

User STARTTLS when this capability is available and the connection is not secured.

STARTTLS is used to secure an insecure connection right after connecting to the server before authenticating.

By default this is enabled.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.HostPort = 143
  objImap.Secure = False
  objImap.UseStartTls = True
  objImap.Connect strServer, strServerAccount, strServerPassword 
  
  ' ...  
  
  objImap.Disconnect 

AutoClose property

Automatically close the currently selected mailbox before disconnecting.

Closing the mailbox will finalize all operations for that mailbox.

This is enabled by default.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.AutoClose = False
  objImap.IpVersion = objConstants.IPVERSION_6
  objImap.Connect strServer, strServerAccount, strServerPassword 
  
  ' ...  
  
  objImap.Close
  objImap.Disconnect 

IpVersion property

Set the IP version to be used when connecting to the server.

Find the possible values here.

By default this is version 4

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.AutoClose = False
  objImap.IpVersion = objConstants.IPVERSION_6
  objImap.Connect strServer, strServerAccount, strServerPassword 
  
  ' ...  
  
  objImap.Close
  objImap.Disconnect 

Secure property

Enabled secure (SSL/TLS) connecting to the server.

Set this value before calling connect to setup a secured connection to the server.

If this value is set to False the client will automatically try 'STARTTLS' right after connecting to secure the connection before sending the user name and password.

The default value is 'False'.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.HostPort = 993
  objImap.Secure = True
  objImap.Authentication = objConstants.IMAP_AUTH_AUTO
  objImap.Connect strServer, strServerAccount, strServerPassword 
  
  ' ...  
  
  objImap.Disconnect 

LastImapResponse property

Contains the last response from the server.

Right after connecting this will contain the server welcome message.

The last IMAP response may sometimes contain extra information that will be useful in case of troubleshooting.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  WScript.Echo objImap.LastImapResponse
  WScript.Echo objImap.Capabilities
  
  ' ...  
  
  objImap.Disconnect 

HierarchySeparator property

Contains the path separator used by the server. This string should always be a single character.

The IMAP server may decide what it uses as a path separator. For instance: '/' (Departments/Sales), '.' (Departments.Sales), or even '' when no sub-mailboxes are supported.

Any call to the List method will update the hierarchy separator.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  objImap.List "", ""
  WScript.Echo objImap.HierarchySeperator
  
  ' ...  
  
  objImap.Disconnect 

Capabilities property

Contains a space (' ') separated string of capabilities supported by the server.

The capabilities represent extensions on the default IMAP protocol that are supported by the server.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  WScript.Echo objImap.LastImapResponse
  WScript.Echo objImap.Capabilities
  
  ' ...  
  
  objImap.Disconnect 

Exists property

Total number of emails that exist in the currently selected mailbox.

The Imap component automatically updates this information based on unsolicited fetch data that may be sent by the IMAP server as a response to any command.

To make sure this information is always current try to periodically call the Noop method.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  objImap.Select "INBOX"
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  WScript.Echo "Total: " & objImap.Exists
  WScript.Echo "Unseen: " & objImap.Unseen
  WScript.Echo "Recent: " & objImap.Recent
  WScript.Echo "Next UID: " & objImap.UidNext
  
  ' ...  
  
  objImap.Disconnect 

Recent property

The number of recent messages in the currently selected mailbox.

The Imap component automatically updates this information based on unsolicited fetch data that may be sent by the IMAP server as a response to any command.

To make sure this information is always current try to periodically call the Noop method.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  objImap.Select "INBOX"
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  WScript.Echo "Total: " & objImap.Exists
  WScript.Echo "Unseen: " & objImap.Unseen
  WScript.Echo "Recent: " & objImap.Recent
  WScript.Echo "Next UID: " & objImap.UidNext
  
  ' ...  
  
  objImap.Disconnect 

Unseen property

The number of unseen emails that exist in the currently selected mailbox.

The Imap component automatically updates this information based on unsolicited fetch data that may be sent by the IMAP server as a response to any command.

To make sure this information is always current try to periodically call the Noop method.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  objImap.Select "INBOX"
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  WScript.Echo "Total: " & objImap.Exists
  WScript.Echo "Unseen: " & objImap.Unseen
  WScript.Echo "Recent: " & objImap.Recent
  WScript.Echo "Next UID: " & objImap.UidNext
  
  ' ...  
  
  objImap.Disconnect 

UidNext property

The next UID that will be used by the IMAP server.

The Imap component automatically updates this information based on unsolicited fetch data that may be sent by the IMAP server as a response to any command.

To make sure this information is always current try to periodically call the Noop method.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  objImap.Select "INBOX"
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If
  
  WScript.Echo "Total: " & objImap.Exists
  WScript.Echo "Unseen: " & objImap.Unseen
  WScript.Echo "Recent: " & objImap.Recent
  WScript.Echo "Next UID: " & objImap.UidNext
  
  ' ...  
  
  objImap.Disconnect 

TimeoutConnect property

Contains the connection timeout. If a connection could not be established within this time the connection is aborted.

The default value is 5000 milliseconds.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.TimeoutConnect = 5000
  objImap.TimeoutCommand = 5000
  objImap.TimeoutAppend = 60000
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If  
  
  ' ...  
  
  objImap.Disconnect 

TimeoutCommand property

Contains the command timeout. If an IMAP server does not respond to any command within this time the command as well as the connection is aborted. This goes for any command except for Append which has its own TimeoutAppend property.

The default value is 5000 milliseconds.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.TimeoutConnect = 5000
  objImap.TimeoutCommand = 5000
  objImap.TimeoutAppend = 60000
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If  
  
  ' ...  
  
  objImap.Disconnect 

TimeoutAppend property

Contains the timeout for appending a new message to the currently selected mailbox. This timeout is only relevant to the Append method.

Set this value to 0 to disable the timeout and wait forever for the append method to complete.

The default value is 0.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.TimeoutConnect = 5000
  objImap.TimeoutCommand = 5000
  objImap.TimeoutAppend = 60000
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If  
  
  ' ...  
  
  objImap.Disconnect 

FetchMaxNumItemsAtOnce property

This setting is used by all fetch commands: FetchFirst/FetchNext, FetchFirstEmail/FetchNextEmail, FetchFirstEmailHeader/FetchNextEmailHeader.

It determines the number of fetch items that are cached by the Imap component.

Generally speaking a higher number will increase the speed of the Imap component at the expense of memory usage. When fetching small items, like envelope data, a higher value is recommended. When fetching large items, like full email messages, a smaller number is recommended.

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' ... Connect to IMAP Server

  objImap.FetchMaxNumItemsAtOnce = 100
  Set objFetchData = objImap.FetchFirst(objConstants.IMAP_SK_ALL, objConstants.IMAP_FM_ALL)
  While objImap.LastError = 0
    
    WScript.Echo objFetchData.Text
  
    Set objFetchData = objImap.FetchNext
  WEnd
    
  ' ... Other stuff
  
  objImap.Disconnect 

MaximumPendingFetchData property

The maximum number of unsolicited fetch items that will be kept by the Imap component.

Unsolicited fetch data can be collected and removed from the queue by calling GetPendingFetchData.

Unsolicited fetch data will normally only be email flag updates that are sent by the IMAP server when a different client changes or causes changes in the flags of messages in a mailbox that is currently selected.

The default setting is 256 fetch items

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.MaximumPendingFetchData = 100
  objImap.MaximumPendingExpunged = 100
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If  
  
  ' ...  
  
  objImap.Disconnect 

MaximumPendingExpunged property

The maximum number of pending expunged notification that are kept by the Imap component

Expunge notifications are sent by the IMAP Server when an email message is deleted from the currently selected mailbox. Expunge notifications are always sent for the current session as well as any other session that may be running at the same time on the same mailbox.

The default setting is 1024 expunge notifications

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.MaximumPendingFetchData = 100
  objImap.MaximumPendingExpunged = 100
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If  
  
  ' ...  
  
  objImap.Disconnect 

UseSequenceNumForStoreAndCopy property

Use sequence numbers instead of UID's to identify messages with the Store and Copy methods.

The default value is 'False'

Example

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  objImap.UseSequenceNumForStoreAndCopy = False  
  objImap.Connect strServer, strServerAccount, strServerPassword 
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If  
  
  ' ...  
  
  objImap.Disconnect 

7.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 IMAP server
Disconnect Disconnect from the IMAP server
IsConnected Returns the connected state
Select Select a mailbox to manipulate
Examine Select a mailbox to inspect without making changes
Status Update this Imap object to reflect the status of the given mailbox
Close Close the selected mailbox and make any changes permanent
Create Create a new mailbox
Delete Delete the given mailbox
Rename Rename the given mailbox
Subscribe Subscribe to the given mailbox
Unsubscribe Unsubscribe from the given mailbox
Copy Copy email messages to a different mailbox
Store Set, remove or alter mail flags for the given email message(s)
Noop No Operation (Use to gather unsolicited server responses)
Check Request server to do any implementation dependent internal housekeeping
Expunge Permanently removes messages that are flagged for deletion
GetPendingExpunged Get next sequence number of message that was deleted
GetPendingFetchData Get next unsolicited fetch data response (e.g. Message flags update)
List List mailboxes
ListSubscribed List subscribed mailboxes
ListCount Number of mailboxes listed
ListAttributes Mailbox flags for the given list index
ListHasAttribute Check if mailbox with given list index has the given flag set
ListName Name of the mailbox at the given list index
FetchFirstEmail Fetch the first email that matches the given search criteria
FetchNextEmail Fetch the next email
FetchFirstEmailHeader Fetch the first email header that matches the given search criteria
FetchNextEmailHeader Fetch the next email header
FetchFirst Build a custom fetch request for specific fetch data from the server
FetchNext Fetch next according to custom fetch request
Append Append a new email message to the given mailbox
HasCapability Check if the IMAP server supports the given capability
FormatDate Helper to format a date such that it can be used as a parameter or as an expression
FormatTime Helper to format a time such that it can be used as a parameter or as an expression

Clear method

This function resets all properties to their default values.

Parameters:

  • None

Return value:

Always 0.

Example:
Set objImap = CreateObject("AxEmail.Imap")   
....
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 objImap = CreateObject("AxEmail.Imap")                 ' Create new instance
objImap.LicenseKey = "XXXXX-XXXXX-XXXXX"
objImap.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 objImap = CreateObject("AxEmail.Imap")
...
WScript.Echo" result:"  & objImap.LastError &" ,"  & _
  objImap.GetErrorDescription(objImap.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 objImap = CreateObject("AxEmail.Imap")
...
objImap.Sleep 1000
...

SetSecure method

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

Parameters:

  • Port number. Default: 993

Return value:

Always 0.

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

Connect method

This function connects to the IMAP server.

Parameters:

  • Hostname
  • Account
  • Password

Return value:

Always 0.

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

Disconnect method

This function disconnects from the IMAP server.

Parameters:

  • None

Return value:

Always 0.

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

IsConnected method

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

Parameters:

  • None

Return value:

Always 0.

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

Select method

Select a mailbox to manipulate.

The properties Exists, Recent Unseen and UidNext are updated according to the selected/examined mailbox. Unsolicited fetch and expunge responses will always be related to the selected/examined mailbox.

Use Close or Select/Examine a different mailbox to close a selected/examined mailbox.

Closing a mailbox will cause the server make any changes permanent if they have not been made permanent already by the server.

The mailbox: 'INBOX' is the default mailbox for incoming email that should always be present.

Parameters

  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  ' ... 
    
  objImap.SetSecure
  objImap.Connect strServer, strAccount, strPassword
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If

  objImap.Select "INBOX"
  WScript.Echo "Total: " & objImap.Exists
  WScript.Echo "Unseen: " & objImap.Unseen
  WScript.Echo "Recent: " & objImap.Recent
  WScript.Echo "Next UID: " & objImap.UidNext
  
  ' ...
  
  objImap.Disconnect  

Examine method

Select a mailbox to inspect without making changes

The properties Exists, Recent Unseen and UidNext are updated according to the selected/examined mailbox. Unsolicited fetch and expunge responses will always be related to the selected/examined mailbox.

Use Close or Select/Examine a different mailbox to close a selected/examined mailbox.

It's not possible to make changes to the mailbox when it is examined. To make changes please use Select.

The mailbox: 'INBOX' is the default mailbox for incoming email that should always be present.

Parameters

  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  ' ... 
    
  objImap.SetSecure
  objImap.Connect strServer, strAccount, strPassword
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If

  objImap.Examine "INBOX"
  WScript.Echo "Total: " & objImap.Exists
  WScript.Echo "Unseen: " & objImap.Unseen
  WScript.Echo "Recent: " & objImap.Recent
  WScript.Echo "Next UID: " & objImap.UidNext
  
  ' ...
  
  objImap.Disconnect  

Status method

Update this Imap object to reflect the status of the given mailbox without selecting to that mailbox.

The propeties Exists, Recent Unseen and UidNext will be updated but the selected/examined mailbox is not changed. Unsolicited fetch and expunge responses will still be related to the previously selected/examined mailbox.

Parameters

  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
    
  ' ... 
    
  objImap.SetSecure
  objImap.Connect strServer, strAccount, strPassword
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If

  objImap.Status "INBOX"
  WScript.Echo "Total: " & objImap.Exists
  WScript.Echo "Unseen: " & objImap.Unseen
  WScript.Echo "Recent: " & objImap.Recent
  WScript.Echo "Next UID: " & objImap.UidNext
  
  ' ...
  
  objImap.Disconnect  

Close method

Close the selected mailbox and make any changes permanent

Parameters

  • None

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Select "Drafts"  
     
  ' .. delete the message referenced by nUid and close the mailbox
  objImap.Store nUid, objConstants.IMAP_MAIL_FLAG_DELETED, objConstants.IMAP_STO_ADD  
  objImap.Close
    
  ' .. do other stuff

Create method

Create a new mailbox.

It's possible to use the HierarchySeparator to create sub-mailboxes to existing mailboxes.

Parameters

  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Create "Drafts" & objImap.HierarchySeparator & "Test"
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Delete method

Delete the given mailbox

Parameters

  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Delete "Drafts" & objImap.HierarchySeparator & "Test"
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Rename method

Rename the given mailbox

Parameters

  • Original mailbox name
  • New mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Rename "Drafts" & objImap.HierarchySeparator & "Test", _
    "Drafts" & objImap.HierarchySeparator & "Test_Renamed"
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Subscribe method

Subscribe to the given mailbox

Parameters

  • Mailbox name

The subscribe option is intended to make managing easier when there are a large number of mailboxes present or when IMAP is used for browsing Usenet servers.

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Subscribe "comp.programming"
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Unsubscribe method

Unsubscribe from the given mailbox

Parameters

  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Unsubscribe "comp.lang.java"
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Copy method

Copy email messages in ID set to target mailbox

The ID set is composed of either UID's or sequence numbers depending on the value of UseSequenceNumForStoreAndCopy.

Multiple ID's are separated by a ','. Ranges are indicated with a ':'. No whitespace is allowed. Example: 3,10:15 will copy messages 3 and 10 to 15.

Parameters

  • ID set
  • Target mailbox name

Return Value

Always 0

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Copy "3,10:15", "INBOX"
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Store method

Use store to update the email flags of a given set of messages.

The ID set is composed of either UID's or sequence numbers depending on the value of UseSequenceNumForStoreAndCopy.

Multiple ID's are separated by a ','. Ranges are indicated with a ':'. No whitespace is allowed. Example: 3,10:15 will copy messages 3 and 10 to 15.

Applicable flags can be found here.

Applicable options can be found here.

NOTE: To delete an email set the flag IMAP_MAIL_FLAG_DELETED and call Expunge

Parameters

  • ID set
  • Flags
  • Option

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Store "3,10:15", objConstants.IMAP_MAIL_FLAG_DELETED, objConstants.IMAP_STO_ADD  
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Noop method

No Operation. This operation does nothing on the server.

The Noop method is intended to be used to retrieve unsolicited fetch data as well as unsolicited expunge ID's.

When the connection is idle. Periodically call the Noop method and subsequently call GetPendingFetchData and GetPendingExpunged until LastError is set after calling either of those functions.

The properties Exists, Recent Unseen and UidNext are updated after calling Noop.

Parameters

  • None

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  While objImap.IsConnected    

    objImap.Noop
    
    ' get all fetch data; they will be email flags that are updated
    Set objFetchData = objImap.GetPendingFetchData
    While objImap.LastError = 0
      WScript.echo objFetchData.Text
      Set objFetchData = objImap.GetPendingFetchData
    WEnd
  
    ' get all expunged data; they will be sequence numbers of deleted messages
    nExpunged = objImap.GetPendingExpunged
    While objImap.LastError = 0
      WScript.Echo nExpunged
      nExpunged = objImap.GetPendingExpunged
    WEnd
  
    ' ... do other stuff ... 
  
    objImap.Sleep 5000
  WEnd  
  
  ' ... disconnect

Check method

Requests the server to do any implementation depended internal housekeeping

The use of this command depends on the IMAP server implementation.

Parameters

  • None

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Check
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If
         
  ' .. do other stuff

Expunge method

Permanently removes messages that are flagged for deletion using the Store method.

Use GetPendingExpunged to find the sequence numbers of messages that have been deleted.

Parameters

  • None

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Store "3,10:15", objConstants.IMAP_MAIL_FLAG_DELETED, objConstants.IMAP_STO_ADD  
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If

  objImap.Expunge
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If

  nExpunged = objImap.GetPendingExpunged
  While objImap.LastError = 0
    WScript.Echo nExpunged
    nExpunged = objImap.GetPendingExpunged
  WEnd
  
  ' .. do other stuff

GetPendingExpunged method

Get the next sequence number of a message that was deleted.

NOTE: After every sequence number that was retrieved all of the sequence numbers on the server are updated. Example: The mailbox has messages with sequence number: 1, 2, 3. Messages 2 and 3 are deleted. GetPendingExpunged will return 2, 2 subsequently.

Parameters

  • None

Return Value

Sequence number of deleted message

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' .. setup connection .. 
  
  objImap.Store "3,10:15", objConstants.IMAP_MAIL_FLAG_DELETED, objConstants.IMAP_STO_ADD  
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If

  objImap.Expunge
  If objImap.LastError <> Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1  
  End If

  nExpunged = objImap.GetPendingExpunged
  While objImap.LastError = 0
    WScript.Echo nExpunged
    nExpunged = objImap.GetPendingExpunged
  WEnd
  
  ' .. do other stuff

GetPendingFetchData method

Returns the next unsolicited pending ImapFetchData object.

These fetch data packets may be sent by the server to notify a client that a different client caused the server to update message flags.

Parameters

  • None

Return Value

ImapFetchData

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  While objImap.IsConnected    

    objImap.Noop
    
    ' get all fetch data; they will be email flags that are updated
    Set objFetchData = objImap.GetPendingFetchData
    While objImap.LastError = 0
      WScript.echo objFetchData.Text
      Set objFetchData = objImap.GetPendingFetchData
    WEnd
  
    ' get all expunged data; they will be sequence numbers of deleted messages
    nExpunged = objImap.GetPendingExpunged
    While objImap.LastError = 0
      WScript.Echo nExpunged
      nExpunged = objImap.GetPendingExpunged
    WEnd
  
    ' ... do other stuff ... 
  
    objImap.Sleep 5000
  WEnd  
  
  ' ... disconnect

List method

List mailboxes on the server.

To access the mailbox information use the methods ListCount, ListName and ListAttributes.

The reference path is the like the working directory on a file system. The mailbox name is like the file specification after the 'dir' command on a file system.

Leave the reference empty ("") to use an absolute mailbox name like used in the Select method.

The following wild cards are supported:

  • * - Maches zero or more characters at this position. Including the hierarchy separator
  • % - Maches zero or more characters at this position. Not including the hierarchy separator

NOTE: Since the server may support symbolic linking sub-mailboxes to super mailboxes infinitely recursive mailboxes may exist. Therefore the client must guard against this by prefering to use '%' over '*' and limiting recurse depth.

Parameters

  • Reference path
  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.List "", "%"      ' list all emails directly in the root
  WScript.Echo "List, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  WScript.Echo
  
  nCount = objImap.ListCount
  WScript.Echo "Found " & objImap.ListCount & " mailboxes:"
  If nCount > 0 Then
    For i = 0 To nCount - 1
      strMailboxName = objImap.ListName(i)
      strMailboxAttributes = objImap.ListAttributes(i)
      
      WScript.Echo "  "  & strMailboxName & ": " & strMailboxAttributes
    Next
  End If

  ' ... do other stuff  

ListSubscribed method

Works the same as MethList only on the subscribed mailboxes.

Parameters

  • Reference path
  • Mailbox name

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.ListSubscribed "", "%"      ' list all emails directly in the root
  WScript.Echo "List, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  WScript.Echo
  
  nCount = objImap.ListCount
  WScript.Echo "Found " & objImap.ListCount & " mailboxes:"
  If nCount > 0 Then
    For i = 0 To nCount - 1
      strMailboxName = objImap.ListName(i)
      strMailboxAttributes = objImap.ListAttributes(i)
      
      WScript.Echo "  "  & strMailboxName & ": " & strMailboxAttributes
    Next
  End If

  ' ... do other stuff  

ListCount method

Use this method after calling either List or ListSubscribed to get the number of items listed.

Parameters

  • None

Return Value

Number of mailboxes listed

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.ListSubscribed "", "%"      ' list all emails directly in the root
  WScript.Echo "List, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  WScript.Echo
  
  nCount = objImap.ListCount
  WScript.Echo "Found " & objImap.ListCount & " mailboxes:"
  If nCount > 0 Then
    For i = 0 To nCount - 1
      strMailboxName = objImap.ListName(i)
      strMailboxAttributes = objImap.ListAttributes(i)
      
      WScript.Echo "  "  & strMailboxName & ": " & strMailboxAttributes
    Next
  End If

  ' ... do other stuff  

ListAttributes method

Use this method after calling either List or ListSubscribed to get the attributes of the item listed at the given index.

Find a list of possible mailbox flags here.

Parameters

  • List index

Return Value

Mailbox flags

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.ListSubscribed "", "%"      ' list all emails directly in the root
  WScript.Echo "List, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  WScript.Echo
  
  nCount = objImap.ListCount
  WScript.Echo "Found " & objImap.ListCount & " mailboxes:"
  If nCount > 0 Then
    For i = 0 To nCount - 1
      strMailboxName = objImap.ListName(i)
      strMailboxAttributes = objImap.ListAttributes(i)
      
      WScript.Echo "  "  & strMailboxName & ": " & strMailboxAttributes
    Next
  End If

  ' ... do other stuff  

ListHasAttribute method

Use this method after calling either List or ListSubscribed to find out if an attribute is present on the item listed at the given index.

Find a list of possible mailbox flags here.

Parameters

  • List index
  • Mailbox flag

Return Value

True if the flag was set else false

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.ListSubscribed "", "%"      ' list all emails directly in the root
  WScript.Echo "List, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  WScript.Echo
  
  nCount = objImap.ListCount
  WScript.Echo "Found " & objImap.ListCount & " mailboxes:"
  If nCount > 0 Then
    For i = 0 To nCount - 1
      strMailboxName = objImap.ListName(i)
      strMailboxAttributes = objImap.ListAttributes(i)
      
      WScript.Echo "  "  & strMailboxName & ": " & strMailboxAttributes
      WScript.Echo "Cannot select: " & objImap.ListHasAttribute(i, objConstants.IMAP_MBX_FLAG_NOSELECT)
    Next
  End If

  ' ... do other stuff  

ListName method

Use this method after calling either List or ListSubscribed to find out if an attribute is present on the item listed at the given index.

Parameters

  • List index

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.ListSubscribed "", "%"      ' list all emails directly in the root
  WScript.Echo "List, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  WScript.Echo
  
  nCount = objImap.ListCount
  WScript.Echo "Found " & objImap.ListCount & " mailboxes:"
  If nCount > 0 Then
    For i = 0 To nCount - 1
      strMailboxName = objImap.ListName(i)
      strMailboxAttributes = objImap.ListAttributes(i)
      
      WScript.Echo "  "  & strMailboxName & ": " & strMailboxAttributes
    Next
  End If

  ' ... do other stuff  

FetchFirstEmail method

Fetch the first email that matches the given search criteria use FetchNextEmail to find subsequent messages based on the same query message.

The search command is a query string. Search keywords can be found here.

Searching for all, unseen or recent messages can be done by simply using 'IMAP_SK_ALL', 'IMAP_SK_UNSEEN' or 'IMAP_SK_RECENT' constants.

Some queries may require a date. To make sure the date is formatted in the right way use the helper function FormatDate.

Find more detailed information on how to formulate more complicated queries here.

Parameters

  • Search criteria

Return Value

Message

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  Set objEmail = objImap.FetchFirstEmail(objConstants.IMAP_SK_UNSEEN)
  While objImap.LastError = 0
    
    WScript.Echo "MessageID        : " & objEmail.ImapUID
    WScript.Echo "   From          : " & objEmail.FromAddress
    WScript.Echo "   From Name     : " & objEmail.FromName
    WScript.Echo "   To            : " & objEmail.ToAddress
    WScript.Echo "   Subject       : " & objEmail.Subject
    WScript.Echo "   Date          : " & objEmail.Date  
    WScript.Echo vbCrLf 
  
    Set objEmail = objImap.FetchNextEmail
  WEnd

  ' ... do other stuff  

FetchNextEmail method

Fetch any subsequent email messages matching the query from FetchFirstEmail.

Parameters

  • None

Return Value

Message

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  Set objEmail = objImap.FetchFirstEmail(objConstants.IMAP_SK_UNSEEN)
  While objImap.LastError = 0
    
    WScript.Echo "MessageID        : " & objEmail.ImapUID
    WScript.Echo "   From          : " & objEmail.FromAddress
    WScript.Echo "   From Name     : " & objEmail.FromName
    WScript.Echo "   To            : " & objEmail.ToAddress
    WScript.Echo "   Subject       : " & objEmail.Subject
    WScript.Echo "   Date          : " & objEmail.Date  
    WScript.Echo vbCrLf 
  
    Set objEmail = objImap.FetchNextEmail
  WEnd

  ' ... do other stuff  

FetchFirstEmailHeader method

Fetch the first email header that matches the given search criteria use FetchNextEmailHeader to find subsequent email headers based on the same query message.

This returns an email object that only contains the headers of the message. So the will be no message body or attachments available.

Parameters

    Search criteria

Return Value

Message

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  Set objEmail = objImap.FetchFirstEmailHeader(objConstants.IMAP_SK_UNSEEN)
  While objImap.LastError = 0
    
    WScript.Echo "MessageID        : " & objEmail.ImapUID
    WScript.Echo "   From          : " & objEmail.FromAddress
    WScript.Echo "   From Name     : " & objEmail.FromName
    WScript.Echo "   To            : " & objEmail.ToAddress
    WScript.Echo "   Subject       : " & objEmail.Subject
    WScript.Echo "   Date          : " & objEmail.Date  
    WScript.Echo vbCrLf 
  
    Set objEmail = objImap.FetchNextEmailHeader
  WEnd

  ' ... do other stuff  

FetchNextEmailHeader method

Fetch any subsequent email headers matching the query from FetchFirstEmailHeader.

Parameters

  • None

Parameters

    None

Return Value

Message

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  Set objEmail = objImap.FetchFirstEmailHeader(objConstants.IMAP_SK_UNSEEN)
  While objImap.LastError = 0
    
    WScript.Echo "MessageID        : " & objEmail.ImapUID
    WScript.Echo "   From          : " & objEmail.FromAddress
    WScript.Echo "   From Name     : " & objEmail.FromName
    WScript.Echo "   To            : " & objEmail.ToAddress
    WScript.Echo "   Subject       : " & objEmail.Subject
    WScript.Echo "   Date          : " & objEmail.Date  
    WScript.Echo vbCrLf 
  
    Set objEmail = objImap.FetchNextEmailHeader
  WEnd

  ' ... do other stuff  

FetchFirst method

Build a custom fetch request consisting of search criteria as well as a fetch specification. Find subsequent items using FetchNext.

Refer to FetchFirstEmail to find more information about the search criteria that are possible.

The fetch specification can be defined using either these constants or one of these fetch macros.

For more complicated fetch specification options have a look here.

Parameters

  • Search criteria
  • Fetch items specification

Return Value

ImapFetchData

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  Set objFetchData = objImap.FetchFirst(objConstants.IMAP_SK_ALL, objConstants.IMAP_FM_ALL)
  While objImap.LastError = 0
    
    ' Get the top-level envelope element from the fetch data
    Set objEnvelope = objFetchData.GetSubDataByName("ENVELOPE")
    Set objFrom = objEnvelope.GetSubData(2).GetSubData(0)
    Set objTo = objEnvelope.GetSubData(4).GetSubData(0)
    
    WScript.Echo "Email UID: " & objFetchData.GetSubDataByName("UID").Value
    WScript.Echo "  Date: "    & objEnvelope.GetSubData(0).Value
    WScript.Echo "  From: "    & objFrom.GetSubData(2).Value & "@" & objFrom.GetSubData(3).Value
    WScript.Echo "  To: "      & objTo.GetSubData(2).Value & "@" & objTo.GetSubData(3).Value
    WScript.Echo "  Subject: " & objEnvelope.GetSubData(1).Value
    WScript.Echo
    
    Set objFetchData = objImap.FetchNext
  WEnd

  ' ... do other stuff  

FetchNext method

Fetch any subsequent items that match the query specified in FetchFirst.

Parameters

  • None

Return Value

ImapFetchData

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ... connect
  
  objImap.Select "INBOX"
  Set objFetchData = objImap.FetchFirst(objConstants.IMAP_SK_ALL, objConstants.IMAP_FM_ALL)
  While objImap.LastError = 0
    
    ' Get the top-level envelope element from the fetch data
    Set objEnvelope = objFetchData.GetSubDataByName("ENVELOPE")
    Set objFrom = objEnvelope.GetSubData(2).GetSubData(0)
    Set objTo = objEnvelope.GetSubData(4).GetSubData(0)
    
    WScript.Echo "Email UID: " & objFetchData.GetSubDataByName("UID").Value
    WScript.Echo "  Date: "    & objEnvelope.GetSubData(0).Value
    WScript.Echo "  From: "    & objFrom.GetSubData(2).Value & "@" & objFrom.GetSubData(3).Value
    WScript.Echo "  To: "      & objTo.GetSubData(2).Value & "@" & objTo.GetSubData(3).Value
    WScript.Echo "  Subject: " & objEnvelope.GetSubData(1).Value
    WScript.Echo
    
    Set objFetchData = objImap.FetchNext
  WEnd

  ' ... do other stuff  

Append method

Append a new email message to the given mailbox.

NOTE: This will not send an email but just append it to a given mailbox.

Parameters

  • Mailbox name
  • Message
  • Flags
  • Date/Time

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objEmail = CreateObject("AxEmail.Message")
  Set objConstants = CreateObject("AxEmail.Constants")

  ' ... connect ...
  
  objEmail.FromAddress = "bill.gates@microsoft.com"
  objEmail.AddTo strAccount & "@" & strServer
  objEmail.Subject = "I desperately need your opinion"
  objEmail.BodyPlainText = "Where should we go next with Microsoft?"  
   
  objImap.Append "Travel", objEmail
  WScript.Echo "Append, result: " & objImap.LastError & _
    " (" & objImap.GetErrorDescription( objImap.LastError ) & ")"
  
  ' ... do other stuff ...

HasCapability method

Find out if the server supports the given capability.

Parameters

  • Capability name

Return Value

True if the given capability is supported else False

Example:

  Set objImap = CreateObject("AxEmail.Imap")  
  Set objConstants = CreateObject("AxEmail.Constants")
  
  objImap.SetSecure
  objImap.Connect strServer, strAccount, strPassword
  If objImap.LastError <> 0 Then 
    WScript.Echo objImap.GetErrorDescription(objImap.LastError)
    WScript.Quit 1
  End If

  WScript.Echo objImap.HasCapability("SPECIAL-USE")
  
  ' ...
  
  objImap.Disconnect

FormatDate method

Helper to format a date. This can be used in all of the fetch methods in the search criteria.

Parameters

  • Year
  • Month
  • Day

Return Value

Date string

Example:

  Set objImap = CreateObject("AxEmail.Imap")  

  ' ...
  
  WScript.Echo objImap.FormatDate(2018, 11, 27)
  
  ' ...

FormatTime method

Helper to format a time. This can be used, together with FormatDate in Append.

Parameters

  • Hour
  • Minute
  • Second
  • Timezone + Daylight saving offset in minutes

Return Value

Always 0

Example:

  Set objImap = CreateObject("AxEmail.Imap")  

  ' ...
  
  WScript.Echo objImap.FormatTime(14, 25, 00, 60)
  
  ' ...

8. ImapFetchData

8.1. Introduction

The ImapFetchData object represents some data item that was fetched from the IMAP server using FetchFirst/FetchNext.

Fetch data may be nested. This means that a fetch data object may be a collection of other fetch data objects which may in turn be a collection of other fetch data objects, etc.

This is an example on using the FetchData object:

  Set objImap = CreateObject("AxEmail.Imap")
  Set objConstants = CreateObject("AxEmail.Constants")
  
  ' ...

  Set objFetchData = objImap.FetchFirst(objConstants.IMAP_SK_ALL, objConstants.IMAP_FM_ALL)
  While objImap.LastError = 0
    
    ' Get the top-level envelope element from the fetch data
    Set objEnvelope = objFetchData.GetSubDataByName("ENVELOPE")
    Set objFrom = objEnvelope.GetSubData(2).GetSubData(0)
    Set objTo = objEnvelope.GetSubData(4).GetSubData(0)
    
    WScript.Echo "Email UID: " & objFetchData.GetSubDataByName("UID").ValueAsInt
    WScript.Echo "  Date: "    & objEnvelope.GetSubData(0).Value
    WScript.Echo "  From: "    & objFrom.GetSubData(2).Value & "@" & objFrom.GetSubData(3).Value
    WScript.Echo "  To: "      & objTo.GetSubData(2).Value & "@" & objTo.GetSubData(3).Value
    WScript.Echo "  Subject: " & objEnvelope.GetSubData(1).Value
    WScript.Echo
    
    Set objFetchData = objImap.FetchNext
  WEnd
  
  ' ...

8.2. Properties

Property Type Read/Write Description
LastError Number Read Result of the last called method
Value String Read Value of this data item as string
ValueAsInt Integer Read The value of this data item as integer
Type Integer Read The type of this value as determined by the parser
Text String Read The raw protocol text representation of this fetch data item and all its sub-items
IsTopLevel Boolean Read Whether this fetch data item is a top level item or a sub-item

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.

Value property

This is the actual value of the current data item represented as a string.

ValueAsInt property

This is the actual value of the current data item represented as an integer.

Type property

The type of this value as determined by the parser. Can be one of these constants.

Text property

The raw protocol text representation of this fetch data item and all its sub-items. This is mainly intended for troubleshooting purposes.

IsTopLevel property

Contains whether this fetch data item is a top level item or a sub-item.

An ImapFetchData object that was returned directly from FetchFirst/FetchNext will always have this property set to True. Sub items will always have this property set to False.

8.3. Methods

Method Description
GetErrorDescription Get the description of the given error
GetSubDataCount Get the number of sub-data items that are contained in this data item
GetSubData Get a sub-data item by index
GetSubDataByName Get a sub-data item by name; only for top-level fetch data items
ContainsValue Check if this data item or one of its sub-data items contains the given value
ContainsIntValue Check if this data item or one of its sub-data items contains the given integer value

GetErrorDescription method

GetErrorDescription provides the error description of a given error code.

Parameters:

  • The error code

Return value:

The error string.

GetSubDataCount method

Parameters

  • None

Return Value

The number of sub-data items

GetSubData method

Parameters

  • Index

Return Value

ImapDataItem

GetSubDataByName method

Parameters

  • Fetch Data Name

Return Value

ImapDataItem

ContainsValue method

Parameters

  • Value as string

Return Value

True if the value is found else False

ContainsIntValue method

Parameters

  • Value as integer

Return Value

True if the value is found else False

9. Message

9.1. Introduction

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

9.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
ImapFlags String Read The message flags reported by the IMAP protocol
ImapUID Integer Read The UID of the message reported by the IMAP protocol
ImapSequenceNumber Integer Read/Write The sequence number of the message reported by the IMAP protocol

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  
...

ImapFlags property

Contains the message flags as reported by the IMAP protocol. Find a list of the possible flags here.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.ImapFlags
WScript.Echo objMessage.ImapUID
WScript.Echo objMessage.ImapSequenceNumber
...

ImapUID property

Contains the message Unique IDentifier (UID) as reported by the IMAP protocol.

This UID uniquely identifies the message within a given mailbox. This is as opposed to the ImapSequenceNumber.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.ImapFlags
WScript.Echo objMessage.ImapUID
WScript.Echo objMessage.ImapSequenceNumber
...

ImapSequenceNumber property

Contains the message sequence number as reported by the IMAP protocol.

The sequence number is a message index within the selected mailbox. The sequence number changes when messages with a lower sequence number are deleted.

Example:

Set objMessage = CreateObject("AxEmail.Message")
...
WScript.Echo objMessage.ImapFlags
WScript.Echo objMessage.ImapUID
WScript.Echo objMessage.ImapSequenceNumber
...

9.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
  • Display name of the attachment

Return value:

Always 0.

Example:
Set objMessage = CreateObject("AxEmail.Message")   
...
objMessage.AddAttachment "C:\Temp\file.zip", "File package"
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  
...

10. Constants

10.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
...

10.2. Constants

IP Version definitions

Constant Value Description
IPVERSION_4 0 Use IP version 4 (default)
IPVERSION_6 1 Use IP version 6
IPVERSION_6_4 2 Use IP version 6, fall back to version 4

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

IMAP Authentication definitions

Constant Value Description
IMAP_AUTH_AUTO 0 Auto detect (default)
IMAP_AUTH_LOGIN 1 AUTH-LOGIN authentication
IMAP_AUTH_PLAIN 2 AUTH-PLAIN authentication

IMAP Search Key definitions

Constant Value Description
IMAP_SK_ALL ALL All messages
IMAP_SK_ANSWERED ANSWERED Messages with 'answered' flag set
IMAP_SK_BCC BCC Containing the specified string in the BCC field
IMAP_SK_BEFORE BEFORE <Date> Before the date specified
IMAP_SK_BODY BODY <String> Containing the specified string in the body of the message
IMAP_SK_CC CC <String> Containing the specified string in the CC field
IMAP_SK_DELETED DELETED Messages with 'deleted' flag set
IMAP_SK_DRAFT DRAFT Messages with 'draft' flag set
IMAP_SK_FLAGGED FLAGGED Messages with 'flagged' flag set
IMAP_SK_FROM FROM <String> Containing the specified string in the FROM field
IMAP_SK_HEADER HEADER <Field> <String> Containing the specified header field with string value. If the string is empty all messages with specified header field are matched.
IMAP_SK_KEYWORD KEYWORD <Flag> Messages with the specified keyword flag set
IMAP_SK_LARGER LARGER <Size> Messages larger than specified number of bytes
IMAP_SK_NEW NEW Messages with 'new' flag set
IMAP_SK_NOT NOT <Search key> Messages that don't match specified search key
IMAP_SK_OLD OLD Messages that do not have the 'recent' flag set
IMAP_SK_ON ON <Date> Messages whose date is within the specified date.
IMAP_SK_OR OR <Search key> <Search key> Messages that match either search key
IMAP_SK_RECENT RECENT Messages with 'recent' flag set
IMAP_SK_SEEN SEEN Messages with 'seen' flag set
IMAP_SK_SENTBEFORE SENTBEFORE <Date> Sent before date
IMAP_SK_SENTON SENTON <Date> Sent on date
IMAP_SK_SENTSINCE SENTSINCE <Date> Sent since date
IMAP_SK_SINCE SINCE <Date> whose date is within or later than date
IMAP_SK_SMALLER SMALLER <Size> Messages smaller than specified number of bytes
IMAP_SK_SUBJECT SUBJECT <String> Containing the specified string in the SUBJECT field
IMAP_SK_TEXT TEXT <String> Containing the specified string in the header or body
IMAP_SK_TO TO <String> Containing the specified string in the TO field
IMAP_SK_UID UID <String> Matching the specified UID. Sequence ranges are allowed
IMAP_SK_UNANSWERED UNANSWERED Messages that do not have the 'answered' flag set
IMAP_SK_UNDELETED UNDELETED Messages that do not have the 'deleted' flag set
IMAP_SK_UNDRAFT UNDRAFT Messages that do not have the 'draft' flag set
IMAP_SK_UNFLAGGED UNFLAGGED Messages that do not have the 'flagged' flag set
IMAP_SK_UNKEYWORD UNKEYWORD <Flag> Messages that do not have the specified keyword flag set
IMAP_SK_UNSEEN UNSEEN Messages that do not have the 'seen' flag set

IMAP Fetch Macro definitions

Constant Value Description
IMAP_FM_ALL ALL Equivalent to (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE)
IMAP_FM_FAST FAST Equivalent to (FLAGS INTERNALDATE RFC822.SIZE)
IMAP_FM_FULL FULL Equivalent to (FLAGS INTERNALDATE RFC822.SIZE ENVELOPE BODY)

IMAP Fetch Data Items definitions

Constant Value Description
IMAP_FDI_BODY BODY Non-extensible form of BODYSTRUCTURE
IMAP_FDI_BODY BODY [<section>]<<part>> Specific part of message body. Find detailed information in the IMAP RFC
IMAP_FDI_HEADER HEADER Use together with BODY to fetch a part of the body
IMAP_FDI_HEADER_FIELDS HEADER.FIELDS Use together with BODY to fetch a part of the body
IMAP_FDI_HEADER_FIELDS_NOT HEADER.FIELDS_NOT Use together with BODY to fetch a part of the body
IMAP_FDI_MIME MIME Use together with BODY to fetch a part of the body
IMAP_FDI_TEXT TEXT Use together with BODY to fetch a part of the body
IMAP_FDI_BODY_PEEK BODY_PEEK Alternative form of BODY[<section>] that does not set the 'seen' flag
IMAP_FDI_BODYSTRUCTURE BODYSTRUCTURE The MIME body structure of the message
IMAP_FDI_ENVELOPE ENVELOPE The envelope structure of the message
IMAP_FDI_FLAGS FLAGS The flags that are set for this message
IMAP_FDI_INTERNALDATE INTERNALDATE The internal date of the message
IMAP_FDI_RFC822 RFC822 Equivalent to BODY[<section>]<<part>>
IMAP_FDI_RFC822_HEADER RFC822.HEADER Equivalent to BODY.PEEK[HEADER] with different return syntax
IMAP_FDI_RFC822_SIZE RFC822.SIZE The size of the message
IMAP_FDI_RFC822_TEXT RFC822.TEXT Equivalent to BODY[TEXT] with different return syntax
IMAP_FDI_UID UID The Unique ID of the message

IMAP Mailbox Flags definitions

Constant Value Description
IMAP_MBX_FLAG_NOINFERIORS \Noinferiors No sub-mailboxes are possible
IMAP_MBX_FLAG_NOSELECT \Noselect It is not possible to use this name as a selectable mailbox
IMAP_MBX_FLAG_MARKED \Marked The mailbox was marked 'interesting' by the server
IMAP_MBX_FLAG_UNMARKED \Unmarked The mailbox does not contain addition messages since the last select
IMAP_MBX_FLAG_ALL \All (Special Use) All messages in the users message store
IMAP_MBX_FLAG_ARCHIVE \Archive (Special Use) Used to archive messages
IMAP_MBX_FLAG_DRAFTS \Drafts (Special Use) Save draft messages
IMAP_MBX_FLAG_FLAGGED \Flagged (Special Use) Flagged messages
IMAP_MBX_FLAG_JUNK \Junk (Special Use) Junk messages
IMAP_MBX_FLAG_SENT \Sent (Special Use) A copy of sent messages
IMAP_MBX_FLAG_TRASH \Trash (Special Use) Trash messages
IMAP_MBX_FLAG_HASNOCHILDREN \HasNoChildren (Child Mailbox) This mailbox has no child mailboxes
IMAP_MBX_FLAG_HASCHILDREN \HasChildren (Child Mailbox) This mailbox has child mailboxes

IMAP Mail Flags definitions

Constant Value Description
IMAP_MAIL_FLAG_SEEN \Seen Message has been read
IMAP_MAIL_FLAG_ANSWERED \Answered Message has been answered
IMAP_MAIL_FLAG_FLAGGED \Flagged Message is" flagged" for urgent/special attention
IMAP_MAIL_FLAG_DELETED \Deleted Message is" deleted" for removal by later EXPUNGE
IMAP_MAIL_FLAG_DRAFT \Draft Message has not completed composition (marked as a draft).
IMAP_MAIL_FLAG_RECENT \Recent Message is" recently" arrived in this mailbox.

IMAP Fetch Data Type definitions

Constant Value Description
IMAP_FD_TYPE_INTEGER 1 Integer
IMAP_FD_TYPE_STRING 2 String - String value
IMAP_FD_TYPE_STRING_LITERAL 3 String - String with possible newlines
IMAP_FD_TYPE_LIST 4 List - List of sub-fetch-data items
IMAP_FD_TYPE_ATOM 5 Atom - Keyword or short, simple string value
IMAP_FD_TYPE_NIL 6 NIL - Represents NULL

IMAP Store Option definitions

Constant Value Description
IMAP_STO_SET 1 Set to this exact value
IMAP_STO_ADD 2 Add the given flag to the existing flags
IMAP_STO_REMOVE 3 Remove the given flag from the existing flags
IMAP_STO_SILENT 4 Don't result in an unsolicited fetch message.

11. Support

11.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/.

11.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

12. Purchase and Activation

12.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

12.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.

13. Appendix A - License agreement

13.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