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 C++ project, the first step is "Add header files of EASendMail to your project". Please go to "C:\Program Files\EASendMail\Include\tlh" or "C:\Program Files (x86)\EASendMail\Include\tlh" folder, find "easendmailobj.tlh" and "easendmailobj.tli", and then copy these files to your project folder.
// include the following header files to your C++ project. #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/JScript/WSH/MS SQL Stored Procedure 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
To use EASendMail SMTP ActiveX Object in your Delphi project, the first step is "Add Unit file of EASendMail to your project". Please go to "C:\Program Files\EASendMail\Include\delphi" or "C:\Program Files (x86)\EASendMail\Include\delphi" folder, find "EASendMailObjLib_TLB.pas", and then copy this file to your project folder.
// include EASendMailObjLib_TLB unit to your Delphi Project unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, EASendMailObjLib_TLB, StdCtrls;
Then you can start to use EASendMail SMTP ActiveX Object in your Delphi Project.
You can also create EASendMailObjLib_TLB.pas manually by Delphi like this:
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.
First of all, create a standard delphi project: select menu Component -> Import component... -> Import a type library -> checked "EASendMailObj ActiveX Object", have "Generate Component Wrapper" checked 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.
In windows vista/7/8 or later version, you MUST open DOS command by "run as administrator", otherwise, regsvr32 will be failed.
To start a command prompt as an administrator Click Start, click All Programs, and then click Accessories. Right-click Command prompt, and then click Run as administrator. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue. To start a command prompt as an administrator (alternative method) Click Start. In the Start Search box, type cmd, and then press CTRL+SHIFT+ENTER. If the User Account Control dialog box appears, confirm that the action it displays is what you want, and then click Continue.
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\Lib\native\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 |
Lib\native\x86\EASendMailObj.dll | 32 bit |
Lib\native\x64\EASendMailObj.dll | 64 bit |
Distribute EASendMail ActiveX Object by Manifest file
For VB6, C++, DELPHI or other standard exe application, you can distribute EASendMailObj.dll with your application to target machine without COM-registration. To learn more detail, please have a look at Registration-free COM with Manifest File.
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
Registration-free COM with Manifest
User Authentication and SSL Connection
Enable TLS 1.2 on Windows XP/2003/2008/7/2008 R2
Using Gmail SMTP OAUTH
Using Gmail/GSuite Service Account + SMTP OAUTH Authentication
Using Office365 EWS OAUTH
Using Office365 EWS OAUTH in Background Service
Using Hotmail SMTP OAUTH
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 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