Documentation

Add

CPosting::Add(
   $arFields
);

The method Add is used to add a new issue (newsletter, message).

Parameters

ParameterDescription
$arFields Associated array containing the keys and values of the Issue object fields. The following fields can also be used:
  • RUB_ID - array of the mailing list ID's;
  • GROUP_ID - array of the user group ID's.

Return Values

Returns the issue ID on success. In case of an error, it returns false and the class variable LAST_ERROR contains the error description.

Example



$posting = new CPosting;
$arFields = Array(
    "FROM_FIELD" => $FROM_FIELD,
    "TO_FIELD" => $TO_FIELD,
    "BCC_FIELD" => $BCC_FIELD,
    "EMAIL_FILTER" => $EMAIL_FILTER,
    "SUBJECT" => $SUBJECT,
    "BODY_TYPE" => ($BODY_TYPE <> "html"? "text":"html"),
    "BODY" => $BODY,
    "DIRECT_SEND" => ($DIRECT_SEND <> "Y"? "N":"Y"),
    "CHARSET" => $CHARSET,
    "SUBSCR_FORMAT" => ($SUBSCR_FORMAT<>"html" && $SUBSCR_FORMAT<>"text"? 
        false:$SUBSCR_FORMAT), 
    "RUB_ID" => $RUB_ID,
    "GROUP_ID" => $GROUP_ID
);
if($STATUS <> "")
{
    if($STATUS<>"S" && $STATUS<>"E" && $STATUS<>"P")
        $STATUS = "D";
    $arFields["STATUS"] = $STATUS;
    if($STATUS == "D")
    {
        $arFields["DATE_SENT"] = false;
        $arFields["SENT_BCC"] = "";
        $arFields["ERROR_EMAIL"] = "";
    }
}
$ID = $posting->Add($arFields);
if($ID == false)
    echo $posting->LAST_ERROR;
© «Bitrix24», 2001-2024
Up