your requirement needs to be developed but no worries its possible i attached code for you this will help to develop.
procedure SendPaperStatementMail(Var Rec_AccountNumber: Text)
var
email: Codeunit Email;
emailMsg: Codeunit "Email Message";
tempblobcu: Codeunit "Temp Blob";
cnv64: Codeunit "Base64 Convert";
InStr: InStream;
txtB64: Text;
Text001: Text;
RecRef: RecordRef;
Outstreamreport: OutStream;
LoanStatement: Report "Loan Statement Report";
LoanHeader: Record Ecl_LoanHeader;
char13: Char;
char10: Char;
NewLine: Text;
cominfo: Record "Company Information";
custrec: Record customer;
SalesRec: Record "Sales & Receivables Setup";
begin
cominfo.Get();
SalesRec.Get();
LoanHeader.Reset();
LoanHeader.SetRange(AccountNumber, Rec_AccountNumber);
IF LoanHeader.FindFirst() then
if SalesRec.PaperStatementEmail <> '' then
if custrec.get(LoanHeader."Customer No.") then
if custrec.ecl_SendPaperStatement then
if (LoanHeader."Statement Date" <> 0D) or (LoanHeader."Statement No" <> 0) then begin
RecRef.GetTable(LoanHeader);
tempblobcu.CreateOutStream(Outstreamreport);
Report.SaveAs(50191, 'Test', ReportFormat::Pdf, Outstreamreport, RecRef);
char13 := 13;
char10 := 10;
NewLine := char10;
Text001 := StrSubstNo('Dear %1,', LoanHeader.name);
Text001 += NewLine + NewLine;
Text001 += StrSubstNo('Please find attached your monthly statement for your Coogans Account %1 which has a current balance of $%2.',
LoanHeader.AccountNumber, format(ROUND(LoanHeader.LastClosingBalance, 0.01, '='), 0, '<Precision,2:2><Standard Format,0>'));
Text001 += NewLine + NewLine;
Text001 += StrSubstNo('The minimum payment required for this month is $%1 and it is due on %2.', format(ROUND(LoanHeader.Minimum_Payment, 0.01, '=') +
LoanHeader.Total_Arrears, 0, '<Precision,2:2><Standard Format,0>'), Format(LoanHeader.NextDueDate, 0, '<Day,2>/<Month,2>/<Year4>'));
Text001 += NewLine + NewLine;
Text001 += StrSubstNo('Please contact us on %1 if you have any questions or would like to speak to us about your account.', cominfo."Phone No. 2");
Text001 += NewLine + NewLine;
Text001 += NewLine + NewLine;
Text001 += 'Sincerely';
Text001 += NewLine + NewLine;
Text001 += 'The yyy Team' + NewLine;
Text001 += cominfo."Home Page" + NewLine;
text001 += cominfo."Phone No. 2";
tempblobcu.CreateInStream(InStr);
txtB64 := cnv64.ToBase64(InStr, true);
emailMsg.Create(SalesRec.PaperStatementEmail, StrSubstNo('Paper Statement for the Loan Account No. %1', LoanHeader.AccountNumber), Text001);
emailMsg.AddAttachment('Statement for ' + LoanHeader.name + ' as of ' + Format(LoanHeader."Statement Date", 0, '<Day,2>-<Month,2>-<Year>') + '.pdf', 'application/pdf', txtB64);
IF email.Send(emailMsg) then;
end;
end;