sendmail TacSendMail component
Hierarchy Properties Methods Events
Return to Introduction  Previous page  Next page
The acSendMail component used for sending e-mail messages via SMTP servers. The messages can be either in plain text or HTML format, contain attachments or embedded images for HTML contents. You can use the acSendMail for mass dispatching of messages by mailing lists, specifying multiple recipients.  
For more information about SMTP protocol see RFC 821.  

How to use?
SMTP server  
First you should specify SMTP server which will relay messages to recipients. Set the hostname and port number to SMTPHost and SMTPPort properties. In case if specified SMTP server requires secure authentication — set Authentication.Enabled property to True and provide the Username and Password.  
Sender and recipients  
The name and email address of sender should be specified in FromName and FromAddress properties (or leave them blank if you sending anonymous message). Recipients should be listed in ToAddr, ToCC or ToBCC properties. (Addresses listed in ToBCC (blind carbon-copy) will not be included to the header of message.)  
Set the body of the message to MsgBody and subject of message to MsgSubject property. If you wish to send HTML-formatted message — set MsgContentType to ctHTML. If you use foreign language (with non-latin character) — specify content charset in MsgContentCharset property. Also you can specify the priority (level of importance) of message in MsgPriority property.  
All files which should be attached to message should be listed in Attach property. There are two attachment types — normal and embedded (see AttachType property). Use ctEmbedded type if you wish to use some attached pictures in HTML-based message (see also MsgContentType property).  
Sending or saving the message  
Use Send method to dispatch the message to SMTP server or SaveToFile to save generated message to disk. Use Abort to terminate connection with SMTP server.  
Event handlers  
Write OnProgress and OnResponse event handlers to display the progress and status of dispatching. Hook OnHostUnreachable, OnConnLost and OnSMTPError events to be notified errors (or use OnAnyError event to be notified about ANY fatal error). Write OnSuccess event to notify user about successful dispatching of e-mail message.  
new! Email templates  
The acSendMail can automatically translate the email templates and replace all the keywords like %RECIPIENT_NAME% or %RECIPIENT_EMAIL% to their actual values. You just need to specify some keywords which are used in your template and values which should replace the keywords in the outgoing message. See TemplateConverter property for more details.  

Usage example
In Delphi:  
In C++ Builder:  
Compiled executable:  

See also
acTextTemplateConverter, acThread and acHTTP components;  
SMTP protocol reference (rfc821); MIME references (rfc2045, rfc2046, rfc2047, rfc2048, rfc2049).