web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to send excel sheet attachment mail through AL code

(0) ShareShare
ReportReport
Posted on by 153
Hi Guys,
I want automatically to send excel sheet through mail.
I have one excel sheet. & this sheet is created through excel buffer. i want to send mail this sheet through AL code.
Please let me know Is any way to do this. 
For example: In below image. I have one mail recipient's field. i want to send mail this recipient.
 
I have the same question (0)
  • Janarthananv Profile Picture
    115 on at
    Dear  Nilam bhor,
     
    Please call the function in the button or code unit. This code is working for us. Please give a try and let us know
     
    Please use the given below
     
     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
  • Suggested answer
    Nilam Bhor Profile Picture
    153 on at
    ,
     
     
     
     
    I am using below your code,but getting this error.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,948 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,048 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 727 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans