Answer the question
In order to leave comments, you need to log in
Bitrix CEvent::Send &CFile::MakeFileArray Are there 2 identical files in the message?
Hello everyone, the question is, why are there 2 identical attachments in the letter?
$file = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."/temp/".$MGR_ID.'_'.date("dmYHi").'.xlsx');
$arEventField = array(
"EMAIL_TO" => $USER->GetEmail(),
"USER_NAME" => $USER->GetFullName(),
"FILE" => $file
);
//var_dump($file);
if(CEvent::Send("MGR_INFORMER", 's1', $arEventField,'Y','',$file)){ // array($file) если указать файл в массиве, то вообще файл не прикрепляется...
@unlink($_SERVER["DOCUMENT_ROOT"]."/temp/".$MGR_ID.'_'.date("dmYHi").'.xlsx');
}
array(4) {
["name"]=>
string(19) "1_250720190933.xlsx"
["size"]=>
int(32177)
["tmp_name"]=>
string(70) "/var/www/vhosts/site.ru/httpdocs/temp/1_250720190933.xlsx"
["type"]=>
string(65) "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}
Answer the question
In order to leave comments, you need to log in
1) You do not need to specify the FILE key in $arEventField, it will itself be set from the 6th parameter of the CEvent::Send method
2) \CFile::MakeFileArray does not need to be done at all. On the last Bitrix, they do it for you.
Those. in your case the code should look something like this:
$fileName = $_SERVER["DOCUMENT_ROOT"]."/temp/".$MGR_ID.'_'.date("dmYHi").'.xlsx';
$files = [
$fileName
];
$arEventField = [
"EMAIL_TO" => $USER->GetEmail(),
"USER_NAME" => $USER->GetFullName(),
];
if ( \CEvent::Send("MGR_INFORMER", "s1", $arEventField, "Y", '', $files ) )
{
@unlink($fileName);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question