local procedure Email()
var
Email: Codeunit Email;
EmailMessage: Codeunit "Email Message";
TempBlob: Codeunit "Temp Blob";
ReportParameters: Text;
EmailBody: Text[100];
Subject: Text[100];
Recipient: Text[1000];
InStr: Instream;
OutStr: OutStream;
ReportValves: Text[100];
begin
EmailBody := 'Dear Team, ';
EmailBody += 'Please find attached the reports as of ';
Subject := 'Sample Subject';
ReportValves := 'Sample Report';
ReportValves += '.xlsx';
Recipient := 'Test@gmail.com';
EmailMessage.Create(Recipient, Subject, EmailBody);
TempBlob.CreateOutStream(OutStr);
TempBlob.CreateInStream(InStr);
Report.SaveAs(Report::"Standard Sales - Invoice", ReportParameters, ReportFormat::Excel, OutStr);
EmailMessage.AddAttachment(ReportValves, 'Excel', InStr);
Email.Send(EmailMessage, Enum::"Email Scenario"::Default);
end;
Thanks
Janarthanan v