
Hi experts
I have code unit from NAV 2016 which custom code unit .I used CAL to AL converter To get AL file .but now it showing all errors as many functionality,table ,CU related to mail depreciated from NAV to BC. I am not getting how to move forward Any help will Really appreciated Thanks in Advance!
I have shared code unit Which Converted in AL
codeunit 50001 "Send Mail"
{
trigger OnRun()
begin
end;
var
SMTPMail: Codeunit "400";
SMTPSetup: Record "409";
procedure SendMailToCust(CustNo: Code[20])
var
Customer: Record 18;
CustLedgEntry: Record 21;
SalesPerson: Record 13;
begin
SMTPSetup.GET;
Customer.GET(CustNo);
Customer.TESTFIELD("E-Mail");
SMTPMail.CreateMessage(SMTPSetup."Email Sendor Name", SMTPSetup."Email Sendor Email",
Customer."E-Mail", 'Pending Payments', '', TRUE);
SalesPerson.GET(Customer."Salesperson Code");
IF SalesPerson."E-Mail" <> '' THEN
SMTPMail.AddCC(SalesPerson."E-Mail");
SMTPMail.AppendBody('Dear Sir / Madam,');
SMTPMail.AppendBody('
');
SMTPMail.AppendBody('Please find Pending Payments List.');
SMTPMail.AppendBody('
');
SMTPMail.AppendBody('| Invoice No. | '); SMTPMail.AppendBody('Invoice Date | '); SMTPMail.AppendBody('Due Date | '); SMTPMail.AppendBody('Invoice Amount | '); SMTPMail.AppendBody('Balance Amount | '); SMTPMail.AppendBody('
|---|---|---|---|---|
| ' FORMAT(CustLedgEntry."Document No.") ' | '); SMTPMail.AppendBody('' FORMAT(CustLedgEntry."Posting Date") ' | '); SMTPMail.AppendBody('' FORMAT(CustLedgEntry."Due Date") ' | '); SMTPMail.AppendBody('' FORMAT(CustLedgEntry."Amount (LCY)") ' | '); SMTPMail.AppendBody('' FORMAT(CustLedgEntry."Remaining Amt. (LCY)") ' | '); SMTPMail.AppendBody('
Hi,
There is Email and "Email Message" codeunits that can be used instead of your outdated codeunit.
Below is a sample of simple email sending birthday message. Check their methods if you can append lines in the body.
var
Email: Codeunit Email;
EmailMessage: Codeunit "Email Message";
Subject:='Hello';
ToRecipients:='johnsmith@abc.com';
company:=ReportsCode.getcompname;
Body:='Dear ' + 'John Smith, <br><br>' + 'On behalf of the company wish you very happy birthday! <br><br>'+ company+'<br> HR Department';
EmailMessage.Create(ToRecipients,Subject, Body, true);
Email.Send(EmailMessage);