EASendMail ActiveX Object(COM) References


EASendMailObj consists of two objects: IMail and IFastSender. IMail interface provides the basis of sending email. It supports CC, BCC, multiple attachments and ESMTP authentication. It fully supports asynchronous operating mode and event driving. It also provides advanced features such as embedded picture, alternative text, email digital signature and email encryption. IFastSender interface enables your application to send mass email in a threadings-pool with highest performance. Both IMail and IFastSender can send email under SSL/TLS channel.

Mail

Send email with single thread under synchronous or asynchronous mode. It also provides rich interfaces for email composition.

FastSender

Send mass emails with multiple threadings and very high performance.

Example

[Visual Basic 6.0, C++, JScript, Delphi] 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.

[VB6, VBA - Send Email]

Const ConnectNormal = 0
Const ConnectSSLAuto = 1
Const ConnectSTARTTLS = 2
Const ConnectDirectSSL = 3
Const ConnectTryTLS = 4

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"
    
    ' Your SMTP server address
    oSmtp.ServerAddr = "mail.adminsystem.com"

    ' If you don't have SMTP server, use the following codes to send email via DNS lookup 
    ' It is not recommended, most email providers would reject the email for anti-spam policy
    ' oSmtp.ServerAddr = ""   
    
    ' User and password for ESMTP authentication
    ' If your server doesn't require user authentication, please remove the following codes
    oSmtp.UserName = "test@adminsystem.com"
    oSmtp.Password = "test"
    
    ' ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically
    oSmtp.ConnectType = ConnectTryTLS

    ' If your server uses 587 port 
    ' oSmtp.ServerPort = 587
    
    ' If your server uses 465 port with SSL/TLS 
    ' oSmtp.ConnectType = ConnectSSLAuto 
    ' oSmtp.ServerPort = 465
    
    ' If your server uses 25/587 port with SSL/TLS 
    ' oSmtp.ConnectType = ConnectSSLAuto 
    ' oSmtp.ServerPort = 587

    oSmtp.FromAddr = "test@adminsystem.com"
    oSmtp.AddRecipient "Support Team", "support@adminsystem.com", 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


[ASP Classic, VBScript - Send Email] Const ConnectNormal = 0 Const ConnectSSLAuto = 1 Const ConnectSTARTTLS = 2 Const ConnectDirectSSL = 3 Const ConnectTryTLS = 4 Dim oSmtp Set oSmtp = Server.CreateObject("EASendMailObj.Mail") ' The license code for EASendMail ActiveX Object, ' For evaluation usage, please use "TryIt" as the license code. oSmtp.LicenseCode = "TryIt" ' Your SMTP server address oSmtp.ServerAddr = "mail.adminsystem.com" ' If you don't have SMTP server, use the following codes to send email via DNS lookup ' It is not recommended, most email providers would reject the email for anti-spam policy ' oSmtp.ServerAddr = "" ' User and password for ESMTP authentication ' If your server doesn't require user authentication, please remove the following codes oSmtp.UserName = "test@adminsystem.com" oSmtp.Password = "test" ' ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType = ConnectTryTLS ' If your server uses 587 port ' oSmtp.ServerPort = 587 ' If your server uses 465 port with SSL/TLS ' oSmtp.ConnectType = ConnectSSLAuto ' oSmtp.ServerPort = 465 ' If your server uses 25/587 port with SSL/TLS ' oSmtp.ConnectType = ConnectSSLAuto ' oSmtp.ServerPort = 587 oSmtp.FromAddr = "test@adminsystem.com" oSmtp.AddRecipient "Support Team", "support@adminsystem.com", 0 oSmtp.Subject = "Test email sent from ASP, VBScript" oSmtp.BodyText = "Hello, this is a test...." If oSmtp.SendMail() = 0 Then Response.Write "Message delivered!" Else Response.Write oSmtp.GetLastErrDescription() End If
[JScript/WSH - Send Email] var ConnectNormal = 0; var ConnectSSLAuto = 1; var ConnectSTARTTLS = 2; var ConnectDirectSSL = 3; var ConnectTryTLS = 4; 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"; // Your SMTP server address oSmtp.ServerAddr = "mail.adminsystem.com"; // User and password for ESMTP authentication // If your server doesn't require user authentication, please remove the following codes oSmtp.UserName = "test@adminsystem.com"; oSmtp.Password = "test"; // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType = ConnectTryTLS; // If your server uses 587 port // oSmtp.ServerPort = 587; // If your server uses 465 port with SSL/TLS // oSmtp.ConnectType = ConnectSSLAuto; // oSmtp.ServerPort = 465; // If your server uses 25/587 port with SSL/TLS // oSmtp.ConnectType = ConnectSSLAuto; // oSmtp.ServerPort = 587; oSmtp.FromAddr = "test@adminsystem.com"; oSmtp.AddRecipient("Support Team", "support@adminsystem.com", 0); oSmtp.Subject = "Test email sent from ASP, VBScript"; oSmtp.BodyText = "Hello, this is a test ...."; if(oSmtp.SendMail() == 0) WScript.Echo("Message delivered!"); else WScript.Echo(oSmtp.GetLastErrDescription()); }
[Visual C++ - Send Email] #include "stdafx.h" #include <tchar.h> #include <Windows.h> #include "EASendMailObj.tlh" using namespace EASendMailObjLib; const int ConnectNormal = 0; const int ConnectSSLAuto = 1; const int ConnectSTARTTLS = 2; const int ConnectDirectSSL = 3; const int ConnectTryTLS = 4; void SendEmail() { ::CoInitialize(NULL); IMailPtr oSmtp = NULL; oSmtp.CreateInstance(__uuidof(EASendMailObjLib::Mail)); //The license code for EASendMail ActiveX Object, //for evaluation usage, please use "TryIt" as the license code. oSmtp->LicenseCode = _T("TryIt"); // Your SMTP server address oSmtp->ServerAddr = _T("mail.adminsystem.com"); // User and password for ESMTP authentication // If your server doesn't require user authentication, please remove the following codes oSmtp->UserName = _T("test@adminsystem.com"); oSmtp->Password = _T("test"); // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp->ConnectType = ConnectTryTLS; // If your server uses 587 port // oSmtp->ServerPort = 587; // If your server uses 465 port with SSL/TLS // oSmtp->ConnectType = ConnectSSLAuto; // oSmtp->ServerPort = 465; // If your server uses 25/587 port with SSL/TLS // oSmtp->ConnectType = ConnectSSLAuto; // oSmtp->ServerPort = 587; oSmtp->FromAddr = _T("test@adminsystem.com"); oSmtp->AddRecipient(_T("Support Team"), _T("support@adminsystem.com"), 0); oSmtp->Subject = _T("Test"); oSmtp->BodyText = _T("Hello, this is a test email from VC++ ...."); if (oSmtp->SendMail() == 0) _tprintf(_T("Message delivered!")); else _tprintf((const TCHAR*)oSmtp->GetLastErrDescription()); }
[Delphi - Send Email] unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, EASendMailObjLib_TLB; // add EASendMail unit type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; const ConnectNormal = 0; ConnectSSLAuto = 1; ConnectSTARTTLS = 2; ConnectDirectSSL = 3; ConnectTryTLS = 4; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var oSmtp : TMail; begin oSmtp := TMail.Create(Application); oSmtp.LicenseCode := 'TryIt'; // Set your sender email address oSmtp.FromAddr := 'test@emailarchitect.net'; // Add recipient email address oSmtp.AddRecipientEx('support@emailarchitect.net', 0); // Set email subject oSmtp.Subject := 'simple email from Delphi project'; // Set email body oSmtp.BodyText := 'this is a test email sent from Delphi project, do not reply'; // Your SMTP server address oSmtp.ServerAddr := 'mail.adminsystem.com'; // User and password for ESMTP authentication, // If your server doesn't require user authentication, please remove the following codes oSmtp.UserName := 'test@emailarchitect.net'; oSmtp.Password := 'testpassword'; // ConnectTryTLS means if server supports SSL/TLS connection, SSL/TLS is used automatically oSmtp.ConnectType := ConnectTryTLS; // If your server uses 587 port // oSmtp.ServerPort := 587; // If your server uses 465 port with SSL/TLS // oSmtp.ConnectType := ConnectSSLAuto; // oSmtp.ServerPort := 465; // If your server uses 25/587 port with SSL/TLS // oSmtp.ConnectType := ConnectSSLAuto; // oSmtp.ServerPort := 587; ShowMessage('start to send email ...'); if oSmtp.SendMail() = 0 then ShowMessage('email was sent successfully!') else ShowMessage('failed to send email with the following error: ' + oSmtp.GetLastErrDescription()); end; end.

See Also

Using EASendMail ActiveX Object
Registration-free COM with Manifest File
User Authentication and SSL Connection
From, ReplyTo, Sender and Return-Path
Digital Signature and Email Encryption - S/MIME
DomainKeys Signature and DKIM Signature
Send Email without SMTP server(DNS lookup)
Work with EASendMail Service(Mail Queuing)
Programming with Asynchronous Mode
Programming with FastSender
Mail vs. FastSender
Bulk Email Sender Guidelines
Process Bounced Email (Non-Delivery Report) and Email Tracking
Work with RTF and Word
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
Send Email in VB - Windows Store App
Send Email in C# - Windows Store App
Send Email in JavaScript - Windows Store App