• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/recurring/mail.php
  • Класс: Bitrix\Crm\Recurring\Mail
  • Вызов: Mail::prepareDataFrom
protected function prepareDataFrom($elementId)
{
	$result = new Main\Result();

	$data = \CCrmFieldMulti::GetList(
		array('ID' => 'asc'),
		array(
			'=ELEMENT_ID' => $elementId,
			'=ENTITY_ID' => 'COMPANY',
			'=TYPE_ID' => 'EMAIL'
		)
	);
	$ownerData = $data->Fetch();

	if (!($ownerData) || !check_email($ownerData['VALUE']))
	{
		$result->addError(new Main\Error('Mail sending error. Owner Email is not found'));
		return $result;
	}

	if (isset($ownerData['ENTITY_ID']))
	{
		$ownerTypeName = mb_strtoupper(strval($ownerData['ENTITY_ID']));
	}
	else
	{
		$result->addError(new Main\Error('Mail sending error. Owner type entity is not defined!'));
		return $result;
	}

	$ownerTypeId = \CCrmOwnerType::ResolveID($ownerTypeName);
	if(!\CCrmOwnerType::IsDefined($ownerTypeId))
	{
		$result->addError(new Main\Error('Mail sending error. Owner type is not supported!'));
		return $result;
	}

	$result->setData(
		array(
			'ELEMENT_ID' => $ownerData['ELEMENT_ID'],
			'VALUE' => htmlspecialcharsbx($ownerData['VALUE']),
			'TYPE_ID' => $ownerTypeId
		)
	);

	return $result;
}