I have already done this for single record send mail .
can you please help to resolve it.
but when i apply loop for send more than one record it can't work below are the CodeUnit for sent mail:-
Documentation()
OnRun()
SentMailtoCust(CustNo : Code[20])
SMTPSetup.GET;
IF Customer.FINDSET THEN
REPEAT
UNTIL(Customer.NEXT=0);
Customer.TESTFIELD("E-Mail");
SMTPMail.CreateMessage('',SMTPSetup."User ID",Customer."E-Mail",'Test1','',TRUE);
IF SalesPerson."E-Mail"<>'' THEN
SMTPMail.AddCC(SalesPerson."E-Mail");
SMTPMail.AppendBody('Dear Sir / Madam,');
SMTPMail.AppendBody('<br><br>');
SMTPMail.AppendBody('Please find Pending Payments List.');
SMTPMail.AppendBody('<br><Br>');
SMTPMail.AppendBody('<table border="1">');
SMTPMail.AppendBody('<tr>');
SMTPMail.AppendBody('<th>Invoice No.</th>');
SMTPMail.AppendBody('<th>Invoice Date</th>');
SMTPMail.AppendBody('<th>Due Date</th>');
SMTPMail.AppendBody('<th>Invoice Amount</th>');
SMTPMail.AppendBody('<th>Balance Amount</th>');
SMTPMail.AppendBody('</tr>');
SalesPerson.GET(Customer."Salesperson Code");
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);
IF CustLedgEntry.FINDFIRST THEN
REPEAT
CustLedgEntry.CALCFIELDS("Amount (LCY)");
CustLedgEntry.CALCFIELDS("Remaining Amt. (LCY)");
SMTPMail.AppendBody('<tr>');
SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Document No.")+'</td>');
SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Posting Date")+'</td>');
SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Due Date")+'</td>');
SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Amount (LCY)")+'</td>');
SMTPMail.AppendBody('<td>'+FORMAT(CustLedgEntry."Remaining Amt. (LCY)")+'</td>');
SMTPMail.AppendBody('</tr>');
UNTIL(CustLedgEntry.NEXT=0);
SMTPMail.AppendBody('</table>');
SMTPMail.AppendBody('<br><br>');
SMTPMail.AppendBody('Regards,');
SMTPMail.AppendBody('<br>');
SMTPMail.AppendBody('Ajay Pandey');
SMTPMail.AppendBody('<br><br>');
SMTPMail.AppendBody('<HR>');
SMTPMail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');
SMTPMail.Send;
SendTestMailtoCust(CNo : Code[20])
IF Cust.FINDSET THEN
REPEAT
UNTIL(Cust.NEXT=0);
SMTPSetup.GET;
SMTPMail.Send;
SendMailtoCustWithAttachment(CustNo : Code[20])
SMTPSetup.GET;
IF Customer.FINDSET THEN
REPEAT
UNTIL(Customer.NEXT=0);
Customer.TESTFIELD("E-Mail");
SalesPerson.GET(Customer."Salesperson Code");
IF SalesPerson."E-Mail" <> '' THEN
SMTPMail.AddCC(SalesPerson."E-Mail");
SMTPMail.AppendBody('Dear Sir / Madam,');
SMTPMail.AppendBody('<br><br>');
SMTPMail.AppendBody('Please find Attached Sales Statistics.');
SMTPMail.AppendBody('<br><Br>');
SMTPMail.AppendBody('Regards,');
SMTPMail.AppendBody('<br>');
SMTPMail.AppendBody('Saurav Dhyani');
SMTPMail.AppendBody('<br><br>');
SMTPMail.AppendBody('<HR>');
SMTPMail.AppendBody('This is a system generated mail. Please do not reply to this email ID.');
SMTPMail.Send;
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,228 Super User 2024 Season 2
Martin Dráb 230,056 Most Valuable Professional
nmaenpaa 101,156