Mail Object


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.

Properties

Alias

Specifies user alias in Exchange WebDAV protocol.

AltBody

Specifies alternative text/plain body of current email.

Anonymous

Specifies whether sender's address will be displayed in email

Asynchronous

Specifies the operation mode of current object.

AuthType

Specifies the type of ESMTP authentication.

AutoCalendar

Specifies the e-mail generates text/calendar body with ics attachment automatically.

BodyFormat

Specifies current email body text format.

BodyText

Specifies current email body text.

Charset

Specifies the character set in current email.

ComputerName

Domain name to send in HELO/EHLO command.

DeliveryNotification

Sets the delivery notifications for this e-mail message.

DK_PublicKey

Gets the latest DomainKeys publick key.

Drafts

Specifies the user drafts folder in Exchange WebDAV protocol.

EncryptionAlgorithm

Specifies the algorithm for email encryption.

From

Specifies the original display name of email sender.

FromAddr

Specifies the original sender's email address.

HeaderEncoding

Sets the encoding method of email sender name, recipient name, subject and attachments' name.

KeepConnection

Specifies whether EASendMail disconnects to server after sending an email.

LocalIP

Specify the IP address of local computer to connect server.

LogFileName

Log file to record all transactions between client and server.

Protocol

Specifies the server protocol (SMTP/Exchange Web Service/Exchange WebDAV).

ProxyProtocol

Specifies the proxy server protocol (socks4/socks5/http).

ReadReceipt

Request read receipt in the email message.

RecipientsCerts

Specifies the certificates of recipients to encrypt current email.

LicenseCode

License code of EASendMail Object.

PIPELINING

Gets or sets using PIPELINING extension with SMTP server.

ReplyTo

Reply address of current email.

ReturnPath

Specifies the email address for delivery notification report.

SaveCopy

Specifies if server should save a copy of message in sent folder.

Sender

Specifies the sender's email address.

ServerAddr

SMTP server address, it can be IP address or domain name.

ServerPort

Listening port of SMTP server.

SignatureHashAlgorithm

Specifies the has algorithm for email digital signature.

SignerCert

Specifies the Digital Signature of current email.

SocksProxyServer

Specifies socks4/socks5/http proxy server address.

SocksProxyPort

Specifies socks4/socks5/http proxy port.

SocksProxyUser

Specifies the user for user authentication of proxy server.

SocksProxyPassword

Specifies the password for user authentication of proxy server.

Subject

Subject of current email.

SSL_starttls

Specifies whether current connection uses STARTTLS command to enable SSL/TLS.

TransferEncoding

Specifies the encoding method of email body.

Priority

Specifies the priority level of current email.

Timeout

Specifies the timeout value in seconds.

UserName

User name for ESMTP authentication.

Password

Password for ESMTP authentication.

raw_Content

Sends an email with 100% original format.

Methods

AddAttachment

Attach a file or URL to current email.

AddAttachment1

Attach a binary stream to current email with customized file name.

AddAttachmentEx

Attach a file or URL to current email with customized file name.

AddAttachments

Attach all files in specified directory to current email.

AddHeader

Add customized header to current email.

AddInline

Add an embedded attachment file to current email.

AddInlineEx

Add an embedded attachment file to current email with customized file name.

AddRecipient

Add normal, carbon copy or blind carbon copy recipient to current email.

AddRecipientEx

Add multiple normal, carbon copy or blind carbon copy recipients to current email.

ClearAttachment

Remove all attachments from current email.

ClearHeader

Remove all customized headers from current email.

ClearInline

Remove all embedded attachments from current email.

ClearRecipient

Remove all recipients from current email.

ConvertHTML

Convert BodyText to text format and remove all html tags from message.

CreateFolder

Create a folder in local disk recursively.

DeleteFile

Delete specified file from local disk.

GetAllEmailServers

Retrieve all recipient's local SMTP server addresses via DNS lookup.

GetEmailContent

Get current email's encoded content.

GetEmailHeaders

Get text stream of current email headers.

GetEmailServer

Retrieve recipient's SMTP server address via DNS lookup.

GetLastError

Get latest error code while sending email.

GetLastErrDescription

Get latest error descriptions.

ImportHtml

Imports specified html string with embedded pictures to current email.

ImportMail

Import the content of a file or URL to BodyText.

ImportMailEx

Imports specified html file or URL with embedded pictures to current email.

LoadMessage

Load email from a *.eml file to current object.

LoadRawMessage

Load email from a *.eml file to raw_Content property and send it with 100% original format.

PostToRemoteQueue Send email message to remote EASendMail Service queue.
Reset

Reset most properties to their default values and remove all recipients, attachments.

SaveMail

Save current email to specified email file.

SaveMailEx

Save current email to IIS SMTP Service pickup path.

SetMailer

Specify x-mailer in email header.

SendMail

Send email to specified SMTP server.

SendMailToQueue

Sends an email to EASendMail Service.

SendMailToQueueEx

Sends an email to specified instance of EASendMail Service.

SSL_init

Initializes security library for SMTP SSL/TLS connection.

SSL_uninit

Unload security library for SMTP SSL/TLS connection.

Terminate

Terminate incomplete SendMail method in asynchronous mode.

TestEmailAddr

Test if an email address is valid.

Events

OnAuthenticated

Occur when ESMTP user authentication is successful.

OnClosed

Occur when the connection to server closes.

OnConnected

Occur when the client successfully connects to server.

OnError

Occur when there is an error in sending email.

OnSending

Occur when EASendMail is sending email's content to SMTP server.

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]
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.com"
  '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.com"
      '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.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, VBScript - Send Email]
  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"
 
  oSmtp.ServerAddr = "mail.adminsystem.com" 
  
  'If your server require user authentication 'oSmtp.UserName = "test@adminsystem.com"
      '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.com"
  oSmtp.AddRecipient "Support Team", "support@adminsystem.com", 0
 
  oSmtp.Subject = "Test email sent from VB6, VBA"
  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]
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.com";
  
  //If your server require user authentication //oSmtp.UserName =
      "test@adminsystem.com"; //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.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 <comdef.h>
#include <iostream>

#include "easendmailobj.tlh"
using namespace EASendMailObjLib;

using namespace std;
 
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");
	
  oSmtp->ServerAddr = _T( "mail.adminsystem.com" );
  
  //If your server require user authentication //oSmtp->UserName
      = _T("test@adminsystem.com"); //oSmtp->Password = _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 = _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 )
    cout << _T("Message delivered!") << endl;
  else
    cout << (const TCHAR*)(oSmtp->GetLastErrDescription()) << endl;
}

[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;

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 := 'smtp.emailarchitect.net';

  // 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';

  // If your SMTP server requires SSL connection, please add this
      line // oSmtp.SSL_init();

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