IF Customer.FINDFIRST THEN
repeat
body := '';
TotalRmtAmt := 0.00;
newdate := (CALCDATE('<+1D>', TODAY));
CustLedgEntry.SETCURRENTKEY("Customer No.", Open, Positive, "Due Date", "Currency Code");
CustLedgEntry.SETRANGE(CustLedgEntry."Customer No.", Customer."No.");
CustLedgEntry.SETRANGE(Open, TRUE);
CustLedgEntry.SETRANGE("Due Date", newdate);
CustLedgEntry.SETFILTER(CustLedgEntry."Document Type", '%1', CustLedgEntry."Document Type"::Invoice);
IF CustLedgEntry.FINDFIRST THEN BEGIN
REPEAT
CustLedgEntry.CALCFIELDS("Amount (LCY)");
CustLedgEntry.CALCFIELDS("Remaining Amt. (LCY)");
TotalRmtAmt += CustLedgEntry."Remaining Amt. (LCY)";
UNTIL (CustLedgEntry.NEXT = 0);
End;
if not CustLedgEntry.IsEmpty Then begin
Clear(ReportOutStream);
Clear(ReportInStream);
Clear(body);
Clear(TempBlob);
TempBlob.CreateOutStream(ReportOutStream);
PaymentReminderInvoice.SetRunningValues(Customer."No.", newdate, TotalRmtAmt);
if PaymentReminderInvoice.SaveAs('', ReportFormat::Html, ReportOutStream) then begin
TempBlob.CreateInStream(ReportInStream);
ReportInStream.ReadText(body);
if Customer."E-Mail" <> '' then begin
emailMsg.Create(Customer."E-Mail", 'Invoices Due Tomorrow', body, true);
email.Send(emailMsg, Enum::"Email Scenario"::"Send Invoice Reminders");
end;
end;
end;
UNTIL (Customer.NEXT = 0);