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 ASP .NET VB projects.
You must install and configre Internet Information Services (IIS) before using ActiveEmail with ASP .NET .
If you don't have IIS installed, use the following stpes:
(Click on the picture to enlarge)
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 'Web Site'. In the 'Web Site' dialog, select ASP .NET Web Site. 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 'Website' 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 AEMAILLib
In 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 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
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents textServer As System.Web.UI.WebControls.TextBox
Protected WithEvents buttonSend As System.Web.UI.WebControls.Button
Public objSmtpServer As SmtpServer
Public objSmtpMail As SmtpMail
Protected WithEvents textResult As System.Web.UI.WebControls.TextBox
Protected WithEvents textFromName As System.Web.UI.WebControls.TextBox
Protected WithEvents textMailTo As System.Web.UI.WebControls.TextBox
Protected WithEvents textSubject As System.Web.UI.WebControls.TextBox
Protected WithEvents textBody As System.Web.UI.WebControls.TextBox
Protected WithEvents textResponse As System.Web.UI.WebControls.TextBox
Protected WithEvents labelServer As System.Web.UI.WebControls.Label
Protected WithEvents labelFromAddress As System.Web.UI.WebControls.Label
Protected WithEvents textFromAddress As System.Web.UI.WebControls.TextBox
Protected WithEvents labelFromName As System.Web.UI.WebControls.Label
Protected WithEvents LabelMailTo As System.Web.UI.WebControls.Label
Protected WithEvents labelSubject As System.Web.UI.WebControls.Label
Protected WithEvents labelBody As System.Web.UI.WebControls.Label
Protected WithEvents labelResult As System.Web.UI.WebControls.Label
Protected WithEvents labelResponse As System.Web.UI.WebControls.Label
Public objConstants As EmailConstants
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
objSmtpServer = New SmtpServer()
objSmtpMail = New SmtpMail()
objConstants = New EmailConstants()
End Sub
Private Sub buttonSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles buttonSend.Click
objSmtpServer.LogFile = "C:\\AspNetSmtpLog.txt"
objSmtpServer.Connect(textServer.Text)
If GetResult() = 0 Then
objSmtpMail.FromAddress = textFromAddress.Text
objSmtpMail.FromName = textFromName.Text
objSmtpMail.AddTo(textMailTo.Text, "")
objSmtpMail.Subject = textSubject.Text
objSmtpMail.Body = textBody.Text
objSmtpMail.BodyType = objConstants.asMESSAGE_BODY_PLAIN
objSmtpMail.Encoding = objConstants.asMESSAGE_ENCODING_DEFAULT
objSmtpMail.Priority = objConstants.asMESSAGE_PRIORITY_HIGH
objSmtpServer.Send(objSmtpMail)
GetResult()
End If
End Sub
Private Function GetResult() As Long
GetResult = objSmtpServer.LastError
textResponse.Text = objSmtpServer.LastSmtpResponse
textResult.Text = "ERROR "
& objSmtpServer.LastError.ToString()
& " : " & objSmtpServer.GetErrorDescription(objSmtpServer.LastError)
End Function
End Class
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 ASP .NET (Visual Basic). 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.