Using EASendMail ActiveX Object


Add Reference of EASendMailObj ActiveX Object to Visual Basic 6 Project

To use EASendMail ActiveX Object in your project, the first step is "Add reference of EASendMail ActiveX Object to your project". Please create/open your project with Visual Basic 6, then choose menu->"Project"->"References"->"EASendMailObj ActiveX Object", and click "Open"->"OK", the reference of EASendMail ActiveX Object will be added to your project, and you can start to use EASendMail SMTP ActiveX Object in your Visual Basic 6 Project.

Add Reference of EASendMail ActiveX Object to Visual C++ Project

To use EASendMail SMTP ActiveX Object in your project, please copy "easendmailobj.tlh" and "easendmail.tli" to your Visual C++ Project folder. You can find those files in EASendMail Installation Path\Samples_VC\simple.vcNative. You also need to add the following code in your VC++ header files:

        
#include "easendmailobj.tlh"
using namespace EASendMailObjLib;

Then you can start to use EASendMail SMTP ActiveX Object in your Visual C++ Project.

Add Reference of EASendMail ActiveX Object to VBScript/ASP Project

You just need to install EASendMail ActiveX Object on your machine, then you can use it directly.

Add Reference of EASendMail SMTP ActiveX Object to Delphi Project

First of all, create a standard delphi project: select menu "Project" -> "Import Type Library", checked "EASendMailObj ActiveX Object" and click "Create Unit". Then include "EASendMailObjLib_TLB" in your project.

Deploying EASendMail with Application

EASendMail ActiveX Object is a COM object, you need to copy it to your target machine and run Regsvr32 "c:\my folder\easendmailobj.dll" to register it as a COM object. Download EASendMail installer and run it on your machine, the dll will be registered automatically.

If you want to distribute/deploy without EASendMail installer.
1. copy easendmailobj.dll to destination machine. (run-time file of EASendMail ActiveX Object)
2. run "Regsvr32 [path]\easendmailobj.dll" under dos prompt. (register EASendMail ActiveX Object as com object)

Windows x64(AMD64)

For VBScript/ASP application on Windows x64 platform.
For Visual C++, Delphi application compiled to x64 native code.
Please use the dll in EASendMail installation path\x64\easendmailobj.dll (easendmailobj.dll for x64). 
For Visual Basic 6.0 application, because it is always 32bit application, so it can work fine without EASendMail ActiveX Object X64 File. 

Seperate builds of run-time dll for 32 and x64 platform

File Platform
Installation Path\EASendMailObj.dll 32 bit
Installation Path\x64\EASendMailObj.dll 64 bit

Example

[Visual Basic 6.0, C++, JScript] The following example demonstrates how to send email with EASendMail SMTP Component, but it doesn't demonstrates the events usage. To get the full samples of EASendMail, please refer to Samples section.

[Visual Baisc]		
Private Sub SendEmail()
  Dim oSmtp As EASendMailObjLib.Mail
  Set oSmtp = New EASendMailObjLib.Mail
  
  'The license code for EASendMail ActiveX Object, 
  'for evaluation usage, please use "TryIt" as the license code.
  oSmtp.LicenseCode = "TryIt"
 
  oSmtp.ServerAddr = "mail.adminsystem.net"
  'If you don't have SMTP server, use the following code 
  'send email via DNS lookup, EASendMail lookups SMTP server automatically. 
  'oSmtp.ServerAddr = ""   
  
  'If your server require user authentication 
  'oSmtp.UserName = "test@adminsystem.net"
  'oSmtp.Password = "test"
  
  'If your server requires SSL connection 
  'oSmtp.SSL_init 
  'oSmtp.SSL_starttls = 0 
  'oSmtp.ServerPort = 465
  
  ''If your server requires TLS connection 
  'oSmtp.SSL_init 
  'oSmtp.SSL_starttls = 1 
  'oSmtp.ServerPort = 25
  
  oSmtp.FromAddr = "test@adminsystem.net"
  oSmtp.AddRecipient "Support Team", "support@adminsystem.net", 0
 
  oSmtp.Subject = "Test"
  oSmtp.BodyText = "Hello, this is a test...."
 
  If oSmtp.SendMail() = 0 Then
    MsgBox "Message delivered!"
  Else
    MsgBox oSmtp.GetLastErrDescription()
  End If
End Sub

[JScript/WSH]
function SendEmail()
{
  var oSmtp = new ActiveXObject("EASendMailObj.Mail");
  //The license code for EASendMail ActiveX Object, 
  //for evaluation usage, please use "TryIt" as the license code.
  oSmtp.LicenseCode = "TryIt";  
  
  oSmtp.ServerAddr = "mail.adminsystem.net";
  //If you don't have SMTP server, use the following code 
  //send email via DNS lookup, EASendMail lookups SMTP server automatically. 
  //oSmtp.ServerAddr = ""; 
  
  //If your server require user authentication 
  //oSmtp.UserName = "test@adminsystem.net"; 
  //oSmtp.Password = "test";
  
  //If your server requires SSL connection 
  //oSmtp.SSL_init(); 
  //oSmtp.SSL_starttls = 0; 
  //oSmtp.ServerPort = 465;
  
  //If your server requires TLS connection 
  //oSmtp.SSL_init(); 
  //oSmtp.SSL_starttls = 1; 
  //oSmtp.ServerPort = 25;
    
  oSmtp.FromAddr = "test@adminsystem.net";
  oSmtp.AddRecipient( "Support Team", "support@adminsystem.net", 0 );
 
  oSmtp.Subject = "Test";
  oSmtp.BodyText = "Hello, this is a test....";
  
  if( oSmtp.SendMail() == 0 )
    WScript.Echo( "Message delivered!" );
  else
    WScript.Echo( oSmtp.GetLastErrDescription());
}

[Visual C++]
#include "stdafx.h"
#include <comdef.h>
#include <iostream>

#include "easendmailobj.tlh"
using namespace EASendMailObjLib;

using namespace std;
 
void SendEmail()
{
  ::CoInitialize( NULL );
  IMailPtr oSmtp = NULL;
  oSmtp.CreateInstance("EASendMailObj.Mail");
	
  //The license code for EASendMail ActiveX Object,
  //for evaluation usage, please use "TryIt" as the license code.
  oSmtp->LicenseCode = _bstr_t("TryIt");
	
  oSmtp->ServerAddr = _bstr_t( "mail.adminsystem.net" );
  //If you don't have SMTP server, use the following code 
  //send email via DNS lookup, EASendMail lookups SMTP server automatically. 
  //oSmtp->ServerAddr = _bstr_t("");   
  
  //If your server require user authentication 
  //oSmtp->UserName = _bstr_t("test@adminsystem.net"); 
  //oSmtp->Password = _bstr_t("test");
  
  //If your server requires SSL connection 
  //oSmtp->SSL_init();
  //oSmtp->SSL_starttls = 0; 
  //oSmtp->ServerPort = 465;
  
  //If your server requires TLS connection 
  //oSmtp->SSL_init();
  //oSmtp->SSL_starttls = 1; 
  //oSmtp->ServerPort = 25;  
  
  oSmtp->FromAddr = _bstr_t( "test@adminsystem.net" );
  oSmtp->AddRecipient( _bstr_t("Support Team"), 
                          _bstr_t("support@adminsystem.net"), 0 );
 
  oSmtp->Subject = _bstr_t("Test");
  oSmtp->BodyText = _bstr_t("Hello, this is a test....");
  
  if( oSmtp->SendMail() == 0 )
    cout << "Message delivered!" << endl;
  else
    cout << (const char*)(oSmtp->GetLastErrDescription()) << endl;
}

See Also

Work with EASendMail Service(Mail Queuing)
How to use DomainKeys Signature
Send email without SMTP server(DNS lookup)
Error with sending recipient(Relay denied)
Mail vs. FastSender
Programming with Asynchronous Mode
Digital Signature and Email Encryption
Work with RTF and Word
Programming with FastSender
EASendMail ActiveX Object References
EASendMail SMTP Component Samples

Online Tutorials

Send Email in VB 6.0 - Tutorial
Send Email in C# - Tutorial
Send Email in VB.NET - Tutorial
Send Email in Visual C++ - Tutorial
Send Email in Managed C++/CLI - Tutorial
Send Email in Delphi - Tutorial
Send Email in MS SQL stored procedure - Tutorial