Switch to: V9V8V7V6V5
Table of Contents

MAIL

The MAIL statement allows you to send SMTP based-email using Valentina Server or the Valentina engine built into your application. It can be used with any supported datasource.

This function was added to utilize both the Report Engine and Scheduler for automated delivery of generated reports.

Syntax

vext_mail
    :    __MAIL
         __FROM         character_string_literal_or_var 
         __TO           character_string_literal_or_var	 
         __SUBJECT      character_string_literal_or_var
         __BODY         character_string_literal_or_var
        [__ATTACH       vext_attach_list]
         __SMTP         character_string_literal_or_var
         __PORT         character_string_literal_or_var
        [__USER         character_string_literal_or_var,
         __PASSWORD     character_string_literal_or_var]
        [__SSL          truth_value_or_var]

vext_attach_list
    :    character_string_literal_or_var AS character_string_literal_or_var , ...

character_string_literal_or_var
    :    character_string_literal
    |    variable_name

uint_or_var
    :    UINT
    |    variable_name

truth_value_or_var
    :    truth_value
    |    variable_name

truth_value
    :    TRUE
    |    FALSE

Arguments

  • FROM - email address of sender.
  • TO - email address of recipient. Can be listed few, separated by comma.
  • SUBJECT - the subject of letter.
  • BODY - the body text of letter. Can be plain text or HTML text.
  • ATTACH - list of attachments to letter. Must be encoded by base64 format.
  • SMTP - smpt server to use for sending of letter. It should be in format 'smtp:\\smtp.company.com'.
  • PORT - port of that SMTP server.
  • USER - login of user.
  • PASSWORD - password of user.
  • SSL - TRUE if SSL should be used for SMTP authentication.

Examples

Example:

__MAIL 
    __FROM 'support@company.com' 
    __TO 'client_name@client.com'
    __SUBJECT 'Commercial Offer about us'
    __BODY 'Dear Jon, ...' 
    __SMTP 'smtp://smpt.company.com' 
    __PORT 579

Example:

This example shows usage of MAIL command with SQL variables, what can be fine in stored procedures.

__MAIL FROM @FROM TO @TO
    __SUBJECT @subj 
    __BODY @body
    __SMTP @@smpt 
    __PORT @@smtp_port

Example:

This example shows stored procedure, which generates some report in PDF format, then sends it by email to a client.

CREATE PROCEDURE MAIL_PERSONS()
BEGIN
    DECLARE cur1 CURSOR FOR 
        SELECT f1, f2, f3 FROM tblPerson WHERE fldBirthDate = '2000-01-01'
        FOR REPORT proj_person.person_list AS PDF ENCODE BASE64;

    OPEN cur1; 
        FETCH FIRST cur1 INTO @report1_data; 
    CLOSE cur1; 
 
   __MAIL 
       __FROM 'support@company.com' 
       __TO 'client_name@client.com'
       __SUBJECT 'Person list that are born on New Year'
       __BODY 'Please check attached PDF file.'
       __ATTACH @report1_data AS 'person_list.pdf'
       __SMTP 'smtp://smpt.company.com' 
       __PORT '579'
END