AnsweredAssumed Answered

Scheduler

Question asked by Jagjit Singh on Sep 6, 2016
Latest reply on Sep 7, 2016 by Jagjit Singh

Hi 

 

When i write the below lines then Email is not going .

 

$mail->Body = "<table><tr><th>Sr.</th><th>Name</th><th>Status</th></tr>";
while($row=($leads)){
$mail->Body .= "
<tr>
<td>".$row["name"]."</td><td>".$row["status"]."</td>
</tr> ";
}
$mail->Body .= "</table>"; //close table 

 

After removing it is working fine.

 

<?php

array_push($job_strings, 'MYLEADS');
function MYLEADS() {

$leadsArray = array();
$leadsBean = BeanFactory::getBean('Leads');
$leads = $leadsBean->get_full_list('', "leads.date_entered > SUBDATE(NOW(),12)");
if ($leads != null) {
foreach ($leads as $lead) {
$leadsArray[] = array(
$lead->name,
$lead->status,
);
}
}

/* $mail->isHTML(true); */// Set email format to HTML

$fp = fopen('c:/xampp/tmp/leads.csv', 'w');
foreach ($leadsArray as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);

require_once('include/SugarPHPMailer.php');
$emailObj = new Email();
$defaults = $emailObj->getSystemDefaultEmail();
$mail = new SugarPHPMailer();
$mail->setMailerForSystem();
$mail->From = $defaults['email'];
$mail->FromName = $defaults['name'];
$mail->Subject = 'Leads';
$mail->Body = 'Please find attached all leads from yesterday';

/* $mail->Body = "<table><tr><th>Sr.</th><th>Name</th><th>Status</th></tr>";
while($row=($leads)){
$mail->Body .= "
<tr>
<td>".$row["name"]."</td><td>".$row["status"]."</td>
</tr> ";
}
$mail->Body .= "</table>"; //close table */

$mail->AddAttachment('c:/xampp/tmp/leads.csv');
$mail->AddAddress('jagjit_tcl@yahoo.com');
@$mail->Send();
return true;

}
?>

Thanks

Outcomes