You are here:
ActiveXperts.com > ActiveEmail > How to Use the ActiveEmail > E-mail POP3 > ASP.NET (C#)
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, hebrew and many more), different encodings (including 7/8 bit, quoted-printable, base64).
In this example we are going to use Visual Studio 2008 to create an ASP.NET C# console application project named 'DemoApp' in a solution named 'DemoSolution'. We are going to store this project in the directory 'C:\MyProjects'. All of these names can be changed according to your preferences. This demo project will ask the user to give an e-mail address and a password on the command prompt.
You must install and configure Internet Information Services (IIS) before using the ActiveEmail Toolkit with ASP .NET If you don't have IIS installed, use the following steps:
Download the the ActiveEmail Toolkit from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.
Launch Microsoft Visual Studio 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 and a name for the solution. Also, select the directory where you want to store the project:
Now that a new project has been created, you must add a reference to the ActiveEmail Toolkit in the project to be able to use the the ActiveEmail Toolkit 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 ActiveXperts ActiveEmail Toolkit Type Library' as shown in the following picture:
Click 'OK' to close the 'Add Reference' dialog.
The following code will show how to declare the 'objPop3' and the 'EmailConstants' objects:
namespace CScharpDemo
{
using System;
using System.IO;
using AEmailLib;
public partial class frmPop3 : System.Web.UI.Page
{
private Pop3 objPop3 = null;
private EMailConstants objConstants = null;
The following code will download and display all messages from the POP3 server:
if (objPop3.LastError == 0)
{
for (i = 1; i <= numMessages; i++)
{
objPop3Mail = (EMailMessage)objPop3.GetEmailHeader(i);
txtResult.Text = objPop3.LastError.ToString();
if (objPop3.LastError == 0)
{
lvMessages.Items.Add(objPop3Mail.Date + "; " +
objPop3Mail.FromAddress + "; Subject: " + objPop3Mail.Subject);
}
}
}
You can download the full source code of this project from the ActiveXperts FTP site: ftp://ftp.activexperts-labs.com/samples/smtp-pop3-component/. There are many other working samples included with the product or on the FTP site.
The ActiveEmail Toolkit project ships with a set of Microsoft Visual Studio .NET samples. The projects are created with Microsoft Visual Studio 2008.
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.