You are here:

ActiveXperts.com > Email Component > How to Use > Pop33 > ASP.NET (C#)
ActiveXperts Email Component

Quicklinks

ActiveXperts Email Component is a software development kit (SDK) that enables the user to send (SMTP) and receive (POP3) e-mail messages. ActiveXperts Email Component 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).


Introduction

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.

Prerequisites

You must install and configure Internet Information Services (IIS) before using ActiveXperts Email Component with ASP .NET If you don't have IIS installed, use the following steps:

  • From the Control Panel, click 'Add/Remove Programs'. Select the 'Add/Remove Windows Components' icon from the left pane, then select 'Application Server' and click on 'Details'. You can now select both 'ASP .NET' and 'Internet Information Services (IIS)'. Click 'OK' to continue installation;

Step 1: Download and install ActiveXperts Email Component

Download ActiveXperts Email Component from the ActiveXperts Download Site and start the installation. The installation guides you through the installation process.

Step 2: Create a new ASP .NET C# Project

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:

(Click on the picture to enlarge)

Step 3: Refer to ActiveXperts Email Component Library

Now that a new project has been created, you must add a reference to ActiveXperts Email Component in the project to be able to use ActiveXperts Email Component 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 Email Component Type Library' as shown in the following picture:

ASP.NET C sharp

(Click on the picture to enlarge)

Click 'OK' to close the 'Add Reference' dialog.

Step 4: Declare and create ActiveXperts Email Component objects

The following code will show how to declare the 'objPop3' and the 'Constants' objects:

namespace CScharpDemo
{
  using System;
  using System.IO;
  using AxEmail;

  public partial class frmPop3 : System.Web.UI.Page
  {
    private Pop3 objPop3 = null;
    private Constants objConstants = null;

Step 5: Receive E-mail messages

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.

NOTE: Demo Projects are created with Microsoft Visual Studio 2008

The ActiveXperts Email Component 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.