AnsweredAssumed Answered

Scheduler - Account

Question asked by Jagjit Singh on Sep 11, 2016
Latest reply on Sep 12, 2016 by Offshore Evolution

Hi

  I am getting this error - Unexpected failure, please check PHP logs and sugarcrm.log

 

Below is the Code

 

<?php

array_push($job_strings, 'MYACCOUNTS');
function MYACCOUNTS()
{
$accountsArray = array();
$accountsBean = BeanFactory::getBean('Accounts');
$accounts = $leadsBean->get_full_list('', "accounts.date_entered > SUBDATE(NOW(),2)");

$mailBody = 'Please find details of Accounts Created in Sugar CRM yesterday';
$mailBody .= "<table><tr></tr><tr><th>Sr.</th><th>Name</th><th>Status</th></tr>";
if ($accounts != null)
{
$sr_no = 0;
$mailBody = 'Please find details of Accounts Created in Sugar CRM yesterday';
$mailBody .= "<table><tr></tr><tr><th>Sr.</th><th>Name</th></th><th>Phone</th><th>Status</th></tr>";
foreach ($leads as $lead)
{
$accountsArray[] = array(
$sr_no = $sr_no + 1,
$account->name,
$account->phone_mobile,
$account->status,
);
$mailBody .= "
<tr>
<td>" . $sr_no . "</td><td>" . $account->name . "</td><td>" . $account->phone_mobile . "</td><td>" . $account->status . "</td>
</tr> ";
}
}
else
{
$mailBody = 'No Accounts Created in Sugar CRM yesterday';
}
$mailBody .= "</table>";

 

require_once('include/SugarPHPMailer.php');
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->isHTML(true);
$mail->setMailerForSystem();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = 'Accounts';

$mail->Body = $mailBody;

$mail->AddAddress('jagjit_tcl@yahoo.com');
@$mail->Send();
return true;
}
?>

 

Thanks

Outcomes