codeunit 80123 SendEmailGL
{
Permissions =
tabledata "Gen. Journal Line" = R;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line", 'OnAfterGLFinishPosting', '', false, false)]
local procedure OnAfterGLFinishPosting(GLEntry: Record "G/L Entry"; var GenJnlLine: Record "Gen. Journal Line"; IsTransactionConsistent: Boolean; FirstTransactionNo: Integer; var GLRegister: Record "G/L Register"; var TempGLEntryBuf: Record "G/L Entry" temporary; var NextEntryNo: Integer; var NextTransactionNo: Integer)
OnAfterPostGenJnlLine(GenJnlLine5, SuppressCommit, GenJnlPostLine, IsPosted, GenJournalLine);
var
// //SmtpMailSetup: Record "SMTP Mail Setup";
// //Mail: Codeunit "SMTP Mail";
EmailMessage: Codeunit "Email Message";
Email: Codeunit Email;
Recipients: List of [Text];
gldetails: Record "Gen. Journal Line";
main: Decimal;
Subject: Text;
Body: Text;
GLPostedTitle: Label 'The GL Document %2 of Customer %1 has been posted.';
GLPostedMsg: Label 'Dear Manager<br><br>The GL Document <font color="red"><strong>%2</strong></font> of Customer <strong>%1</strong> has been posted.<br> The total amount is <strong>%3</strong>. <br>The Posted Invoice Number is <strong>%4</strong>. <br> User ID <strong>%5</strong>';
begin
Recipients.Add('dileep.gopinathan@maglube.ae');
Recipients.Add('it@maglube.ae');
// GenJnlLine.CalcFields("Bal. VAT Amount (LCY)");
// GenJnlLine.flowfiled
//Main := gldetails.Amount;
Subject := StrSubstNo(GLPostedTitle, GenJnlLine.SystemCreatedBy, GenJnlLine.Description);
Body := StrSubstNo(GLPostedMsg, GenJnlLine."Amount (LCY)", GenJnlLine."Due Date");
EmailMessage.Create(Recipients, Subject, Body, true);
Email.Send(EmailMessage, Enum::"Email Scenario"::Default);
end;
}