Quicklinks
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 Microsoft Visual Studio .NET environments. This document describes how ActiveEmail can be integrated into Microsoft Visual Basic .NET projects.
Download the ActiveEmail SMTP/POP3 Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
Launch Microsoft Visual Studio (for instance 'Microsoft Visual Studio 2005') from the Start menu. Choose 'New' from the 'File' menu and click on 'Project'. In the 'New Project' dialog, select a Visual Studio template (for instance: 'Console Application'). Select a name for the application (for instance: 'DemoApp') and a name for the solution (for instance: 'DemoSolution'). Also, select the directory where you want to store the project (for instance: 'C:\MyProjects):
(Click on the picture to enlarge)
Now that a new project has been created, you must add a reference to ActiveEmail in the project to be able to use the ActiveEmail objects.
To do so, choose 'Add Reference...' from the 'Project' menu.
In the 'Add Reference' dialog that pops up, select the 'COM' tab and select the 'ActiveEmail 3.0 Type Library' as shown in the following picture:
(Click on the picture to enlarge)
Click 'OK' to close the 'Add Reference' dialog.
On top of your code, type the following line to use the ActiveEmail namespace:Imports AEMAILLibIn your Main function, declare and create the following objects for SMTP:
Dim objSmtpServer As SmtpServer Dim objSmtpMail As SmtpMail objSmtpServer = New SmtpServer() objSmtpMail = New SmtpMail()
To use POP3, declare and create the following objects:
Dim objPop3Server As Pop3Server Dim objPop3Mail As Pop3Mail objPop3Server = New Pop3Server() ' 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 and create the EmailConstants object:
Dim objConstants As EmailConstants objConstants = New EmailConstants()
You can now send and/or receive e-mail messages.
The following code shows how to send an e-mail message:
Imports AEMAILLib
Module Module1
Sub Main()
Dim objSmtpMail As SmtpMail
Dim objSmtpServer As SmtpServer
Dim objConstants As EmailConstants
objSmtpMail = New SmtpMail()
objConstants = New EmailConstants()
objSmtpServer = New SmtpServer()
objSmtpServer.FromAddress = "myname@mycompany.com"
objSmtpServer.FromName = "My Name"
objSmtpServer.Connect("smtp.myserver.com")
Console.WriteLine("Connect, result: " & objSmtpServer.LastError
If (objSmtpServer.LastError = 0) Then
objSmtpMail.AddTo("roger@thecompany.com", "My friend Roger")
objSmtpMail.AddTo("leon@activexperts.com", "My friend Roger")
objSmtpMail.Subject = "Sample 01"
objSmtpMail.Priority = objConstants.asMESSAGE_PRIORITY_MEDIUM
objSmtpMail.BodyType = objConstants.asMESSAGE_BODY_PLAIN
objSmtpMail.Encoding = objConstants.asMESSAGE_ENCODING_DEFAULT
objSmtpMail.Body = "Hello my friend," & vbCrLf & "How are you doing?"
objSmtpServer.Send(objSmtpMail)
Console.WriteLine("Send, result: " & objSmtpServer.LastError
objSmtpServer.Disconnect()
Console.WriteLine("Disconnect (always successfull)")
End If
End Sub
End Module
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.
The ActiveEmail project ships with a set of Microsoft Visual Studio .NET samples, including samples for Microsoft Visual Basic .NET. The projects are created with Microsoft Visual Studio 2005.
Users with a later version of Microsoft Visual Studio can open such a project. The Visual Studio Conversion Wizard will guide you through the process of converting the project to the version used.