Node code below I send an email to a certain recipient however I need the number of invoices everything in it, in the code below it creates an email for each invoice.
I commented on the code where I would like foreach
to be added to work accordingly, but I can not make it work due to syntax.
In short, pass the foreach
that already exists at the top of the code to make only the data of table
and body
of the email that will be sent.
foreach ($class->ListaFaturas($cnpj) as $dados) {
$fatura = $dados->getFatura().'<br>';
$dtemissao = $dados->getDtEmissao().'<br>';
$dtvencimento = $dados->getDtVencimento().'<br>';
$valor = $dados->getVlSaldo().'<br>';
$mail->From = "[email protected]"; #Seu e-mail
$mail->FromName = "teste";
$mail->AddAddress($email,$nome);
$mail->IsHTML(true);
$mail->Subject = "Faturas em atraso";
#Assunto da mensagem
$mail->Body = "
<table>
<thead>
<tr>
<th>Número da Fatura</th>
<th>Data de Emissão</th>
<th>Data de Vencimento</th>
<th>Valor</th>
</tr>
</thead>
<tbody>
<tr>
<!-- Foreach aqui -->
<td>$fatura</td>
<td>$dtemissao</td>
<td>$dtvencimento</td>
<td>$valor</td>
</tr>
</tbody>
</table>
";
$mail->AltBody = "";
$enviado = $mail->Send();
$mail->ClearAllRecipients();
$mail->ClearAttachments();
}