SEND_MAIL

Use the SEND_MAIL script function to send an email to a user. This script function does not verify whether the specified receiver actually exists. The message is sent even if the receiver is not correct. If 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, this script function returns the corresponding return code.

Important!

  • To send emails, you must have configured the Email connection. For more information, see Notification (CALL).
  • This script function always sends emails either through the specified agent or the Automation Engine. Therefore, the files that should be attached must be accessible through the agent or the Automation Engine either directly or through a UNC path.
  • This script statement causes all open transactions of the script to be written to the AE database. For more information, see Script Processing.

Tip: Use the :ON_ERROR script statement to define actions that should take place if the email cannot be sent successfully. For more information, see Script Elements for Error Handling

Syntax

SEND_MAIL (Receiver, [Cc], Subject, Text[, Attachment][, Agent][, Login])

Parameters

  • SEND_MAIL
    Sends an email to a user

  • Receiver
    The address(es) to which the message should be sent
    Format: script literal or script variable

  • Cc
    (Optional) The person that should receive a copy of this message
    Format: script literal or script variable
    Default value: ""

  • 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
    (Optional) Path and name of the files that should be sent as an attachment. Separate the individual paths with a semicolon (;) if you want to send several files.
    Format: script literal or script variable
    Default value: ""

  • Agent
    (Optional) Specifies the agent that should be used for sending the email message(s). If you do not specify this parameter, the default value is used. The system searches for client-wide settings that are defined in the SEND_MAIL_DEFAULT key of the UC_CLIENT_SETTINGS variable. If this key is not defined, the email is sent by through the Automation Engine. For more information, see UC_CLIENT_SETTINGS - Various Client Settings.
    Use one of the following values:

    • Fixed string *DEFAULT (default)
    • Fixed string *SERVER. Use this string to force that the email is sent by the AE/server even if you set a central Agent/login in the UC_CLIENT_SETTINGS variable.
    • Name of the Agent object.
      Important!
      The specified agent and the Automation Engine system must have the same version.
  • Login
    (Optional) Specifies the Login object that is used to send the email message(s). If you do not specify this parameter, the default value is used. The system searches for client-wide settings that are defined in the SEND_MAIL_DEFAULT key of the UC_CLIENT_SETTINGS variable. If this key is not defined, the email is sent by through the Automation Engine. For more information, see UC_CLIENT_SETTINGS - Various Client Settings.
    Important!
    • The Login object used must have an entry with the type MAIL.
    • This parameter is mandatory combined with the Agent parameter.
    • You must have access rights to the files you want to send as attachments.
    • This parameter is ignored if the Agent parameter *SERVER is used. In this case, no Login object is required.

    Value: Name of the Login object

Return Codes

  • 0
    Email was sent successfully
  • 10034
    There is no active host with email connection
  • 50006
    The SMTP server returned an error code
  • 50007
    SMTP server '&02' has rejected the E-mail recipient: '&01'
  • 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
  • 50037
    SMTP Server '&02' replied with Error '&01'
  • 53202
    The setting '&01' you are searching for was not found

Examples

The following example sends an email to exactly one user, the cc parameter is not used. 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: