Documentation

Add

mixed
CEventMessage::Add(
 array fields
)

The method adds a new mail template. Returns an ID of inserted template. In case of an error occurs, returns false, and the LAST_ERROR property of an object will contain error description. Non-static method.

Parameters

ParameterDescription
fields The array of field values of the format array("field"=>"value" [, ...]). The fields can be the following:
  • ACTIVE - mail template active state flag: "Y" - active; "N" - inactive;
  • EVENT_NAME - the mail event type ID;
  • LID - site ID;
  • EMAIL_FROM - the "From" field;
  • EMAIL_TO - the "To" field;
  • BCC - the "BCC" field;
  • SUBJECT - massage header;
  • BODY_TYPE - type of the mail message: "text" or "html";
  • MESSAGE - message body.

If you want to add your own custom field (for example, "envelope-from") specify the ADDITIONAL_FIELD array in fields:

$em = new CEventMEssage;

$arFields = array(
    'ACTIVE'     =>  'Y',
    'EVENT_NAME' =>  'EVENT_NAME',
    //...
    'ADDITIONAL_FIELD'  => array(
        array(
            'NAME'  =>  'envelope-from',
            'VALUE' =>  '#DEFAULT_EMAIL_FROM#'
        )
    )
);

$result = $em->Add( $arFields );

//...

See Also

Examples of use

<?
$arr["ACTIVE"] = "Y";
$arr["EVENT_NAME"] = "ADV_CONTRACT_INFO";
$arr["LID"] = array("en");
$arr["EMAIL_FROM"] = "#DEFAULT_EMAIL_FROM#";
$arr["EMAIL_TO"] = "#EMAIL_TO#";
$arr["BCC"] = "#BCC#";
$arr["SUBJECT"] = "Message test";
$arr["BODY_TYPE"] = "text";
$arr["MESSAGE"] = "
Message test
";

$emess = new CEventMessage;
$emess->Add($arr);
?>


© «Bitrix24», 2001-2024