SEND_MAIL
Script Function: Sends an email to a user.
Syntax
SEND_MAIL (Receiver, [Cc], Subject, Text[, Attachment][, Agent][, Login])
Syntax
|
Description/Format
|
Receiver
|
The person that should receive the message. Format: script literal or script
variable
|
Cc
|
The person that should receive a copy of this message. Format: script literal or script variable Default: ""
|
Subject
|
Short description of the message. Format: script literal or script variable
Maximum length: 255 characters
|
Text
|
Message text. Format: script literal or script variable
|
Attachment
|
The path and the name of the files that should be sent as an attachment. Format: script literal or script variable Default: ""
Separate the individual paths with a semicolon
(;) if you want to send several files.
|
Agent
|
This optional parameter specifies the agent that should be used to send the email message(s).
Value:
-
Name of the Agent object or
- Fixed string "*SERVER" or
- Fixed string "*DEFAULT" (= default value)
If you do not specify an agent here, the default value is applied which means that the system searches for the settings of SEND_MAIL_DEFAULT in the UC_CLIENT_SETTINGS variable. If they do not include any agent specifications, the email is sent by the AE/server
The value "*SERVER" can be used to force sending the email via the AE/server (even if you set a central Agent/login in the UC_CLIENT_SETTINGS).
Warning! The specified agent and the Automation Engine system must have the same version.
|
Login
|
This optional parameter specifies the Login object that is used to send the email message(s). It is essential that you have access to files you want to send as attachments.
Value:
Note: This parameter is ignored if the parameter Agent is set to "*SERVER" (no Login object needed).
Warning! It is mandatory if you specified the Agent parameter.
|
Return codes
|
"0" - Email
was sent successfully. "10034" - There is no active host with email connection. "50006" - The SMTP server returned an error code. "50012" - Timeout - SMTP Server '&02' did not answer within '&01' seconds. "50014" - Attachment does not exist. "50027" - Authentication on the SMTP Server failed. "50028" - The receiver address is not valid. Therefore, the SMTP Server has rejected it. "50029" - The SMTP client cannot connect to the SMTP Server. "50030" - Error in socket creation. "50031" - Host information of the SMTP Server could not be retrieved.
"50032" - The SMTP client cannot communicate with the SMTP Server anymore.
"50033" - The SMTP client cannot receive data from the SMTP Server. "50034" - Data cannot be sent to the SMTP Server. "50035" - Windows sockets cannot be initialized. "50036" - Host name of the local computer cannot be retrieved. "53202" - The setting '&01' you are searching for was not found.
|
This script function does not check whether the specified Receiver actually exists. The message is sent even if the receiver is not correct.
When the email cannot be sent because the attachment cannot be found or the email connection is not active, script processing continues by default. In this case, the script function returns the corresponding return code.
Tip: Use the :ON_ERROR script statement to define action to take if the mail fails. For more information, see Script Elements for Error Handling.
Important! This script function always sends emails either via the specified agent or the Automation Engine. Therefore, files that should be attached must be accessible via the agent or the Automation Engine either directly or via a UNC path.
Notes:
- To send emails, you must have configured the Email connection.
For more information, see Notification (CALL).
- The parameters Agent and Login may also be defined client-wide using the SEND_MAIL_DEFAULT key in the UC_CLIENT_SETTINGS variable. These settings then will be used if the parameters Agent and Login are not specified in the script function SEND_MAIL. For more information, see UC_CLIENT_SETTINGS - Various Client Settings.
- The script statement causes the current transaction of the script to be written to the AE database. For more information, see Script Processing.
Examples
In the following example, an email is sent only to one user (no copies). One file is attached to this
email.
:SET &OUT# = SEND_MAIL('brown@automic.at',,'Meeting','Meeting today at 5pm', '/AE/agenda')
An email that includes two attachments is sent
to several persons:
:SET &OUT# = SEND_MAIL("brown@automic.at;smith@automic.us",,"Meeting","Meeting canceled","c:\AUTOMIC\agenda.doc;c:\AUTOMIC\dates.txt")
See also: