You are here:

ActiveXperts.com > ActiveEmail > How to Use ActiveEmail > Visual Basic 5.x/6.x

ActivEmail SMTP/POP3 Toolkit Add SMTP/POP3 capabilities to any Windows or .NET application

Quicklinks


Using ActiveEmail SMTP/POP3 Toolkit with Visual Basic 5.x/6.x

ActiveEmail SMTP/POP3 Toolkit is a software development kit (SDK) that enables the user to send (SMTP) and receive (POP3) e-mail messages. ActiveEmail supports SMTP, POP3, multiple recipients (To, CC, BCC), multiple attachments (ASCII and binary), rich text body formats (RTF/HTML), Unicode, multiple character sets, SMTP authorization (AUTH PLAIN, AUTH LOGIN, AUTH CRAM MD5), POP3 authorization (Plain, APOP), POP3 header download, different character sets (including arabic, chinese, japanese, russian, greek and many more), different encodings (including 7/8 bit, quoted-printable, base64).

ActiveEmail can be well integrated into Visual Basic environments. This document describes how ActiveEmail can be integrated into Visual Basic 5.x/6.x projects.

Step 1: Download and install ActiveEmail

Download the ActiveEmail SMTP/POP3 Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create a new Visual Basic project

Launch 'Microsoft Visual Basic' from the Start menu, and choose 'New' from the 'File Menu'. The 'New Project' dialog appears. Select 'Standard Exe' and click 'OK':

(Click on the picture to enlarge)

Step 3: Refer to the ActiveEmail Library and declare the objects

A new Project is created, with a blank form.

First, you must add a reference to ActiveEmail in the project to be able to use the ActiveEmail objects. To do so, choose 'References...' from the 'Project' menu. In the 'References' dialog that pops up, enable the 'ActiveEmail 3.0 Type Library' reference as shown in the following picture:

(Click on the picture to enlarge)

Click 'OK' to close the 'References...' dialog.

Then, select the Project form and choose 'View Code' from the context menu:

(Click on the picture to enlarge)

On top of your code, declare the following objects for SMTP:

Public objSmtpServer As AEMAILLib.SmtpServer Public objSmtpMail As AEMAILLib.SmtpMail

and/or declare the following objects for POP3:

Public objPop3Server As AEMAILLib.Pop3Server
Public objPop3Mail   ' NOTE: do NOT create the Pop3Mail object, because it is created by the Pop3Server 
                     ' object when a new message is received

To make use of ActiveEmail's constants, declare the EmailConstants object:

Public objConstants As AEMAILLib.EMailConstants

Step 4: Create the objects

From the Code window, select 'Form'. The Private Sub 'Form_Load()' will be displayed now.

In the 'Form Load' function, create the SMTP objects in the following way:

Set objSmtpServer = CreateObject("ActiveXperts.SmtpServer")
Set objSmtpMail   = CreateObject("ActiveXperts.SmtpMail")

Create the POP3 objects in the following way:

Set objPop3Server = CreateObject("ActiveXperts.Pop3Server")
Set objPop3Mail   = CreateObject("ActiveXperts.Pop3Mail")

Create the constants object in the following way:

Set objConstants  = CreateObject("ActiveXperts.EMailConstants")

Step 5: Send and/or receive an e-mail messages

You can now send and/or receive e-mail messages.

The following code shows how to send an e-mail message (basic e-mail, no error handling):

objSmtpServer.Connect( "smtp.mydomain.com" )  
If( objSmtpServer.LastError = 0 ) Then
   ' Set mail properties
   objSmtpMail.FromAddress  = "sender@mydomain.com" 
   objSmtpMail.FromName     = "ActiveEmail Demo"   
   objSmtpMail.Subject      = "ActiveEmail Message"
   objSmtpMail.Priority     = objConstants.asMESSAGE_PRIORITY_MEDIUM  
   objSmtpMail.BodyType     = objConstants.asMESSAGE_BODY_PLAIN  
   objSmtpMail.Body         = "Hello my friend," & vbCrLf & _
                              "How are you?" & vbCrLf & "Regards."
   objSmtpMail.AddTo "recipient1@myrecipients.com", "Recipient 1"   
   objSmtpMail.AddCc "recipient2@myrecipients.com", "Recipient 2"  

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

There are many working samples included with the product. You can also find them on the ActiveXperts FTP site: ftp.activexperts-labs.com/samples/activemail.