MAIL TO Command

The MAIL TO command sends the specified object as an Internet Mail attachment.

The specified object can be stored in a database, repository or can be opened in a window (in temporary storage).

Syntax

To send an object that resides in a database:

>>-- MAIL ----------- ObjectName TO Address ------------------------<<
          +- QUERY -+             ( +- FROM = Address -----------------------+
          +- PROC --+               +- CCLIST = Address1;Address2 -----------+
          +- FORM --+               +- SUBJECT = Subject --------------------+
                                    +- BODY = Text --------------------------+
                                    +- FORMAT = Text/HTML -------------------+
                                    +- SMTPSERVER = SMTP Server -------------+
                                    +- SMTPPORT = SMTP Server port number ---+
                                    +- SMTPUSER = SMTP Username -------------+
                                    +- SMTPPASSWORD = SMTP Password ---------+
                                    +- DATEFORMAT = Java date format string -+
                                    +- TIMEFORMAT = Java time format string -+
>>-- MAIL ----------- ObjectName TO Address ------------------------<<
          +- TABLE -+             ( +-FROM = Address ----------------------------------------------------+
                                    +- CCLIST = Address1;Address2 ---------------------------------------+
                                    +- DATAFORMAT = CSV/DBF/HTML/IXF/PDF/QMF/SHP/TEXT/WQML/XLS/XLSX/XML -+
                                    +- SUBJECT = Subject ------------------------------------------------+
                                    +- BODY = Text ------------------------------------------------------+
                                    +- FORMAT = Text/HTML -----------------------------------------------+
                                    +- SMTPSERVER = SMTP Server -----------------------------------------+
                                    +- SMTPPORT = SMTP Server port number -------------------------------+
                                    +- SMTPUSER = SMTP Username -----------------------------------------+
                                    +- SMTPPASSWORD = SMTP Password -------------------------------------+
                                    +- DATEFORMAT = Java date format string -----------------------------+
                                    +- TIMEFORMAT = Java time format string -----------------------------+
Note: You can email indexes only if you are connected to Cloudant data sources.
>>-- MAIL ------------ ObjectName TO Address -----------------------<<
          +- REPORT -+            ( +- FROM = Address -----------------------+
                                    +- CCLIST = Address1;Address2 -----------+
                                    +- SUBJECT = Subject --------------------+
                                    +- BODY = Text --------------------------+
                                    +- FORMAT = Text/HTML -------------------+
                                    +- SMTPSERVER = SMTP Server -------------+
                                    +- SMTPPORT = SMTP Server port number ---+
                                    +- SMTPUSER = SMTP Username -------------+
                                    +- SMTPPASSWORD = SMTP Password ---------+
                                    +- DATEFORMAT = Java date format string -+
                                    +- TIMEFORMAT = Java time format string -+
                                    +- TYPE = PDF/HTML-----------------------+
                                    +- METHOD = SPLIT/CONT ------------------+ 
>>-- MAIL ------------------- ObjectName TO Address --------------<<
          +- VISUAL REPORT -+     ( +- FROM = Address ---------------------+
                                    +- CCLIST = Address1;Address2 ---------+
                                    +- SUBJECT = Subject ------------------+
                                    +- BODY = Text ------------------------+
                                    +- FORMAT = Text/HTML -----------------+
                                    +- SMTPSERVER = SMTP Server -----------+
                                    +- SMTPPORT = SMTP Server port number -+
                                    +- SMTPUSER = SMTP Username -----------+
                                    +- SMTPPASSWORD = SMTP Password -------+
                                    +- TYPE = PDF/HTML---------------------+
                                    +- METHOD = SPLIT/CONT ----------------+

To send an object that currently resides in an open window (in temporary storage):

>>-- MAIL --- QUERY --- TO Address --------------------------<<
           +- PROC --+            ( +- FROM = Address -----------------------+
           +- FORM --+              +- CCLIST = Address1;Address2 -----------+
                                    +- SUBJECT = Subject --------------------+
                                    +- BODY = Text --------------------------+
                                    +- FORMAT = Text/HTML -------------------+
                                    +- SMTPSERVER = SMTP Server -------------+
                                    +- SMTPPORT = SMTP Server port number ---+
                                    +- SMTPUSER = SMTP Username -------------+
                                    +- SMTPPASSWORD = SMTP Password ---------+
                                    +- DATEFORMAT = Java date format string -+
                                    +- TIMEFORMAT = Java time format string -+
>>-- MAIL --- REPORT --- TO Address ------------------------<<
                                  ( +- FROM = Address -----------------------+
                                    +- CCLIST = Address1;Address2 -----------+
                                    +- SUBJECT = Subject --------------------+
                                    +- BODY = Text --------------------------+
                                    +- FORMAT = Text/HTML -------------------+
                                    +- SMTPSERVER = SMTP Server -------------+
                                    +- SMTPPORT = SMTP Server port number ---+
                                    +- SMTPUSER = SMTP Username -------------+
                                    +- SMTPPASSWORD = SMTP Password ---------+
                                    +- DATEFORMAT = Java date format string -+
                                    +- TIMEFORMAT = Java time format string -+
                                    +- TYPE = PDF/HTML-----------------------+
                                    +- METHOD = SPLIT/CONT ------------------+ 
>>-- MAIL --- VISUAL REPORT --- TO Address ------------------------<<
                                  ( +- FROM = Address ---------------------+
                                    +- CCLIST = Address1;Address2 ---------+
                                    +- SUBJECT = Subject ------------------+
                                    +- BODY = Text ------------------------+
                                    +- FORMAT = Text/HTML -----------------+
                                    +- SMTPSERVER = SMTP Server -----------+
                                    +- SMTPPORT = SMTP Server port number -+
                                    +- SMTPUSER = SMTP Username -----------+
                                    +- SMTPPASSWORD = SMTP Password -------+
                                    +- TYPE = PDF/HTML---------------------+
                                    +- METHOD = SPLIT/CONT ----------------+
>>-- MAIL --- DATA --- TO Address ----------------------------<<
                                  ( +- FROM = Address ---------------------------------------------------+
                                    +- CCLIST = Address1;Address2 ---------------------------------------+
                                    +- DATAFORMAT = CSV/DBF/HTML/IXF/PDF/QMF/SHP/TEXT/WQML/XLS/XLSX/XML -+
                                    +- SUBJECT = Subject ------------------------------------------------+
                                    +- BODY = Text ------------------------------------------------------+
                                    +- FORMAT = Text/HTML -----------------------------------------------+
                                    +- SMTPSERVER = SMTP Server -----------------------------------------+
                                    +- SMTPPORT = SMTP Server port number -------------------------------+
                                    +- SMTPUSER = SMTP Username -----------------------------------------+
                                    +- SMTPPASSWORD = SMTP Password -------------------------------------+
                                    +- DATEFORMAT = Java date format string -----------------------------+
                                    +- TIMEFORMAT = Java time format string -----------------------------+
>>-- MAIL --- MESSAGE --- TO Address -------------------------<<
                                  ( +- FROM = Address ------------------+
                                    +- CCLIST = Address1;Address2 ---------+
                                    +- SUBJECT = Subject ------------------+
                                    +- BODY = Text ------------------------+
                                    +- FORMAT = Text/HTML -----------------+
                                    +- SMTPSERVER = SMTP Server -----------+
                                    +- SMTPPORT = SMTP Server port number -+
                                    +- SMTPUSER = SMTP Username -----------+
                                    +- SMTPPASSWORD = SMTP Password -------+
                                    +- ATTACHMENT = File1;File2 -----------+
Parameter Description
ObjectName The name of the object to send.
Note: For Cloudant queries, specify the full object key. For Cloudant indexes, specify either the full object key or the design document name and the index name separated by a period (.)
FROM The email of the sender.
CCLIST The email addresses of the recipients.
DATAFORMAT Specifies the file format of the attached data object. If you omit this parameter, the DSQQW_EXP_DT_FRMT global variable supplies the format to be used. You can specify in DSQQW_EXP_DT_FRMT global variable:
  • zero (0) for TEXT format
  • two (2) for HTML format
  • three (3) for CSV format
  • four (4) for IXF format
  • five (5) for dbase III files
  • six (6) for Shapefile format
  • seven (7) for WQML format
  • eight (8) for XML format
  • nine (9) for PDF format
  • ten (10) for XLS format
  • eleven (11) for XLSX format
If you specify IXF, the DSQQW_EXP_OUT_MDE global variable can be set to either zero (0) for character mode System/370 IXF or one (1) for PC/IXF. When exporting reports, HTML format adds the <PRE> tag, TEXT is for a text-based file, and PDF is for a PDF-based file.
SUBJECT The email subject line reference.
BODY The contents of the email message.
FORMAT The email format. Supported formats are Text and HTML.
SMTPSERVER The name of a predefined SMTP server or address of a custom SMTP server.
SMTPPORT The SMTP server port number.
SMTPUSER The user name that is used to authorize on SMTP server.
SMTPPASSWORD The password that is used to authorize on SMTP server.
ATTACHMENT The name and path to the files that will be attached.
TYPE The types that specifies the exported files are visual reports.
METHOD The method separated pages.
DATEFORMAT Specifies how the date is formatted in the HTML, CSV or TXT export file.

Date formats are specified by Java date pattern strings. Within date pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a date string.

Text can be quoted using single quotes (') to avoid interpretation.

Note: If the format string includes spaces, enclose it in quotes. For more information about Java format strings, see the Java 2 SDK, Standard Edition Documentation.
TIMEFORMAT Specifies how the time is formatted in the HTML, CSV or TXT export file.

Time formats are specified by Java time pattern strings. Within time pattern strings, unquoted letters from 'A' to 'Z' and from 'a' to 'z' are interpreted as pattern letters representing the components of a time string.

Text can be quoted using single quotes (') to avoid interpretation.

Note: If the format string includes spaces, enclose it in quotes. For more information about Java format strings, see the Java 2 SDK, Standard Edition Documentation.

Example 1

The following is an example of sending a query, which is opened in the query editor:
MAIL QUERY TO abc@mail.com ( SUBJECT="Opened Query" 
+ SMTPSERVER=smtp.example.com

Example 2

The following is an example of using DATEFORMAT and TIMEFORMAT parameters:
MAIL DATA TO abc@mail.com (DATEFORMAT="dd.MM.yy" TIMEFORMAT="hh:mm" 
+ BODY="DATA" 
+ SUBJECT="DATA" 
+ SMTPSERVER=smtp.example.com FROM=cba@mail.com

Example 3

The following example sends an image to the specified email address in the HTML format:
MAIL MESSAGE TO abc@mail.com (
+ SUBJECT="Image"
+ BODY="<h1>image</h1></br><img src='cid:image.png'></img>"
+ FROM=cba@mail.com
+ SMTPSERVER="smtp.example.com"
+ SMTPUSER=user 
+ SMTPPASSWORD=password 
+ ATTACHMENT="D:/image.png" 
+ FORMAT=HTML

Example 4

The following example sends a Cloudant query that is stored in a repository as an email attachment:

MAIL "rsbi:/.workspaces/Default/Cloudant_query" TO abc@mail.com ( SUBJECT=
"Cloudant query" + SMTPSERVER=smtp.example.com

Example 5

The following examples send a Cloudant index that is stored in a database as a TXT file in an email attachment:

MAIL INDEX "rsbi:/Cloudant Data Sources/Cloudant/exampleViews/
Secondary Indexes/exampleIndex" TO abc@mail.com ( SUBJECT=
"Cloudant index" + SMTPSERVER=smtp.example.com
MAIL INDEX exampleViews.exampleIndex TO abc@mail.com ( SUBJECT=
"Cloudant query" + SMTPSERVER=smtp.example.com

Example 6

The following example sends a Cloudant index that is stored in a database as a Cloudant query in an email attachment:

MAIL "rsbi:/Cloudant Data Sources/Cloudant/exampleViews/
Secondary Indexes/exampleIndex" TO abc@mail.com ( SUBJECT=
"Cloudant index" + SMTPSERVER=smtp.example.com