You are here: > Email Component > How to Use > Smtp > ASP.NET (C#)
ActiveXperts Email Component


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).


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 message body on the command prompt.


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

On top of your code, type the following line to use ActiveXperts Email Component namespace:

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

  public partial class frmsmtp : System.Web.UI.Page
    private Message objEmail = null;
    private Smtp objSmtp = null;
    private Constants objConstants = null;

Step 5: Gather information

The following code will ask the user for the recipient e-mail address and the content of the text message. You can also specify a CC or BCC recipient and you can also add an attachment to your message. This data will be stored in the 'objEmail' object.

// Mail: Clear

// Mail: From
objEmail.FromName = txtFromAddress.Text;
objEmail.FromAddress = txtFromAddress.Text;

// Mail: Encoding
if (ddlEncoding.SelectedIndex == 0)
  objEmail.Encoding = objConstants.EMAIL_MESSAGE_ENCODING_DEFAULT;
    objEmail.Encoding = objConstants.EMAIL_MESSAGE_ENCODING_UTF8;

// Mail: Priority
switch (ddlPriority.SelectedValue)
  case "Highest Priority":
    objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_HIGHEST;
  case "High Priority":
    objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_HIGH;
  case "Normal Priority":
    objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_MEDIUM;
  case "Low Priority":
    objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_LOW;
  case "Lowest Priority":
    objEmail.Priority = objConstants.EMAIL_MESSAGE_PRIORITY_LOWEST;

// Mail: Subject
objEmail.Subject = txtSubject.Text;

// Mail: Body
objEmail.BodyPlainText = txtPlainBody.Text;
objEmail.BodyHtml = txtHtmlBody.Text;

// Mail: To
if( txtToAddress.Text != string.Empty)
  objEmail.AddTo(txtToAddress.Text, txtToAddress.Text);

// Mail: Cc
if( objEmail.LastError == 0 && txtCcAddress.Text != string.Empty)
  objEmail.AddCc(txtCcAddress.Text, txtCcAddress.Text);

// Mail: Bcc
if (objEmail.LastError == 0 && txtCcAddress.Text != string.Empty)
  objEmail.AddBcc(txtBccAddress.Text, txtBccAddress.Text);

Step 6: Send the E-mail message

You can now send E-mail messages.

The following code shows how to send an e-mail message through SMTP:

// Smtp: Send
if(objSmtp.LastError == 0)
  object obj = objEmail;
  objSmtp.Send(ref obj);

You can download the full source code of this project from the ActiveXperts FTP site: 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.