Sending a letter via email. There are no checks, the function works in asynchronous mode and does not make the script slow. A letter in HTML format or as plain text. You can also attach files. Secured connections are provided.

 

Syntax

procedure SendEmail(sHost: string; iPort: integer; sUserName, sPass, sFullEmail: string; bSSL: boolean; sToList, sSubject: string; sMessageText: string; iMsgStyle: integer; sAttachedFiles: string);

 

Parameters and return values

Parameter

Type

Value

sHost

string

IP or domain name of mail server (SMTP);

iPort

integer

network port number;

sUserName

string

user name;

sPass

string

mailbox password;

sFullEmail

string

user's full email address;

bSSL

boolean

use (or not) secured SSL/TLS connection. Many of public mail services (GMail, etc.) require encrypted connection;

sToList

string

list of recipient addresses, separated by commas;

sSubject

string

letter title, text string;

sMessageText

string

letter text;

iMsgStyle

integer

letter type: 0 — plain text, 1 — HTML;

sAttachedFiles

string

list of attached files, separated by the vertical line ("|" symbol). If there are no files, then specify an empty string.

 

You should notice, that this procedure does not return any values, so it's impossible to know whether it was a successful execution or not. Also, sending works instantly in asynchronous mode with no pauses and stops.

 

Example

begin
  SendEmail('smtp.yandex.ru', // SMTP server
            25, // Port number
            'mailbox@yandex.ru', // User name 
            'mysecretpass', // Mailbox password 
            'mailbox@yandex.ru', // Full mailbox name 
            true, // Use SSL/TLS or no 
            'john@mycompany.com,helen@hilton.com, emma@spicegirls.net', // Recipient emails list
            'Test message from MSL, SendEmail function', // Email subject
            'My best friend gave me the best advice,' + CRLF + // Letter text body
            'He said each day''s a gift and not a given right.' + CRLF +
            'Leave no stone unturned, leave your fears behind...' + CRLF +
            'And try to take the path less traveled by.' + CRLF +
            'That first step you take is the longest stride.' + CRLF + CRLF +
            '<i><b>If Today Was Your Last Day</b></i> (Nickelback)',
            1, // Letter format. 0 - plain text, 1 - HTML
            'C:\MyFolder\cover1.jpg|' + // Attached files list (optional), separated by "|" symbol  
            'C:\Users\Toshiba\Pictures\postmessagefrommsl.png');
end.

Script work result

[13:46:18] (Run "SendEmail"): Script operation time: 3 ms

[13:46:18] (Run "SendEmail"): Script done successfully.

 

See also

mSendEmail