I am using this code to trace the pending payment list. The code is :
CLEAR(Mail);
Mail.CreateMessage('MKU Private Limited','nav@mku.com','manish.yadav@mku.com','Pending Payment Invoice List.','',TRUE);
Mail.AppendBody('Dear Sir / Madam');
Mail.AppendBody('<br><br>');
Mail.AppendBody('Please Find Pending Payments List.');
Mail.AppendBody('<HR>');
Mail.AppendBody('<table border="1">');
Mail.AppendBody('<tr>');
Mail.AppendBody('<th>Invoice No.</th>');
Mail.AppendBody('<th>Invoice Date</th>');
Mail.AppendBody('<th>Due Date</th>');
Mail.AppendBody('<th>Currency</th>');
Mail.AppendBody('<th>Invoice Amount</th>');
Mail.AppendBody('<th>Balance Amount</th>');
Mail.AppendBody('<th>Sales Region</th>');
Mail.AppendBody('</tr>');
CustLedgEntry.SETCURRENTKEY("Customer No.", Open, Positive, "Due Date", "Currency Code");
CustLedgEntry.SETRANGE(CustLedgEntry."Customer No.", CustNo);
CustLedgEntry.SETRANGE(Open,TRUE);
CustLedgEntry.SETRANGE(CustLedgEntry."Document Type",CustLedgEntry."Document Type"::Invoice);
CustLedgEntry.SETFILTER(CustLedgEntry."Document Type", 'Invoice');
CustLedgEntry.SETFILTER(CustLedgEntry."Customer No.",'*@C-*');
IF CustLedgEntry.FINDFIRST THEN REPEAT
CustLedgEntry.CALCFIELDS("Amount (LCY)");
CustLedgEntry.CALCFIELDS("Remaining Amt. (LCY)");
Mail.AppendBody('<tr>');
Mail.AppendBody('<td>'+FORMAT(CustLedgEntry."Document No.")+'</td>');
Mail.AppendBody('<td align="center">'+FORMAT(CustLedgEntry."Posting Date")+'</td>');
Mail.AppendBody('<td align="center">'+FORMAT(CustLedgEntry."Due Date")+'</td>');
Mail.AppendBody('<td align="center">'+FORMAT(CustLedgEntry."Currency Code")+'</td>');
Mail.AppendBody('<td align="right">'+FORMAT(CustLedgEntry."Amount (LCY)")+'</td>');
Mail.AppendBody('<td align="right">'+FORMAT(CustLedgEntry."Remaining Amt. (LCY)")+'</td>');
SalesPerson.GET(CustLedgEntry."Salesperson Code");
Mail.AppendBody('<td>'+FORMAT(SalesPerson.Name)+'</td>');
Mail.AppendBody('</tr>');
UNTIL(CustLedgEntry.NEXT=0);
Mail.AppendBody('</table>');
Mail.AppendBody('<br>');
Mail.AppendBody('Regards');
Mail.AppendBody('<br>');
Mail.AppendBody('MKU Sales Department');
Mail.AppendBody(' ');
Mail.AppendBody('<br><br>');
Mail.AppendBody('<HR>');
Mail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');
Mail.Send;
Code is compiled, not showing any error messages. But when we run this code code, always getting error messages... I have attached the screenshots.
I have declare the following variables:
Name DataType Subtype Length
Mail Codeunit SMTP Mail
CustLedgEntry Record Cust. Ledger Entry
SMTPSetup Record SMTP Mail Setup
SalesPerson Record Salesperson/Purchaser
Customer Record Customer
CustNo Text