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...
Unanswered

Send custom quote report by email with description box

(0) ShareShare
ReportReport
Posted on by 5

Hello 

In quote page, I have a created an extension, in which I generate a custom quote report with custom fields. 

I have created too custom buttons : 

- See the report (Voir la simulation) 

- Send the report by email (Envoyer par email) 

The first button works fine, and I can get the dialog box where I can either display the report, or download it in PDF or even word. 

My problem comes with the second button, in which I have created a beginning of SMTP sending but I can see how to get the EDIT - SEND dialog box to send my custom report to the client, with a custom description and object that could be written inside the request box (just like the one that appears when you click on send by email for generic quote report) 

Can somebody help me get through this ? It would be very helpful for me, thanks a lot. 

Code for custom quote page action buttons 

    actions
    {
        addfirst(processing)
        {
            action("Voir la simulation")
            {
                ApplicationArea = All;
                trigger OnAction();

                begin
                    SalesHeader.RESET;
                    SalesHeader.SETRANGE(SalesHeader."Document Type", "Document Type");
                    SalesHeader.SETRANGE(SalesHeader."No.", "No.");
                    SalesHeader.SETRANGE(SalesHeader."Sell-to Customer Name", "Sell-to Customer Name");
                    SalesHeader.SETRANGE(SalesHeader."Sell-to E-Mail", "Sell-to E-Mail");

                    IF SalesHeader.FINDFIRST THEN BEGIN
                        MyReport.SETTABLEVIEW(SalesHeader);
                        MyReport.Run();
                    END;


                end;
            }


            action("Envoyer par email")
            {
                ApplicationArea = All;
                trigger OnAction();
                begin
                    SalesHeader.RESET;
                    SalesHeader.SETRANGE(SalesHeader."Document Type", "Document Type");
                    SalesHeader.SETRANGE(SalesHeader."No.", "No.");

                    IF SalesHeader.FINDFIRST THEN BEGIN

                        MyReport.SETTABLEVIEW(SalesHeader);


                    END;




                    toMail := SalesHeader."Sell-to E-Mail";

                    TempBlob.Blob.CREATEOUTSTREAM(OStream);
                    REPORT.SAVEAS(50103, SalesHeader.GETFILTERS, REPORTFORMAT::Pdf, OStream);
                    TempBlob.Blob.CREATEINSTREAM(ReportInStream);

                    MyPath := 'Simulation'   SalesHeader."Sell-to Customer Name"   '.pdf';
                    SMTP.IsOutlookSetup(SMTPMailSetup);
                    CLEAR(SMTPMail);
                    SMTPMailSetup.GET;
                    SMTPMail.Run();
                    SMTPMail.CreateMessage(
                                'Bail Art',
                                'info@bail-art.com',
                                SalesHeader."Sell-to E-Mail",
                                 'Votre simulation de financement Bail Art',
                                 'Bonjour,
vous trouverez ci-joint votre demande de simulation,
Bien à vous
Bail Art', true); SMTPMail.AddAttachmentStream(ReportInStream, 'Simulation.pdf'); SMTPMail.Send(); MESSAGE('La simulation a été envoyée à ' SalesHeader."Sell-to Customer Name"); rec."Simulation envoyée" := CalcDate('', TODAY); end; } } } var TempBlob: record TempBlob temporary; OStream: OutStream; ReportInStream: InStream; MyPath: Text; SMTPMail: Codeunit "SMTP Mail"; toMail: Text;

Code for custom report 


report 50103 Simulation
{
    // Default layout = word 
    RDLCLayout = 'Layout/Simulation.rdl';
    WordLayout = 'Layout/Simulation.docx';
    DefaultLayout = Word;

    UsageCategory = Documents;
    ApplicationArea = All;
    Caption = 'Simulation';



    dataset
    {

        dataitem("Sales Header"; "Sales Header")
        {


            column(No_; "No.")
            {

            }
            column(Document_Type; "Document Type") { }



            column(Sell_to_Customer_Name; "Sell-to Customer Name")
            {

            }

            column(Sell_to_E_Mail; "Sell-to E-Mail")
            {

            }

            column("Valeur_Résiduelle"; "Valeur Résiduelle") { }

            column(Montant; "Montant")
            {

            }

            column("Imposition"; "Imposition")
            {

            }

            column("Premier_Loyer_Majoré13"; "Premier Loyer Majoré13") { }

            column(Loyer13; Loyer13) { }

            column("Economie_d_Impots_Générée13"; "Economie d'Impots Générée13") { }

            column(Cout_Global13; "Cout Global13") { }


            column("Premier_Loyer_Majoré24"; "Premier Loyer Majoré24") { }
            column(Loyer24; Loyer24) { }

            column("Economie_d_Impots_Générée24"; "Economie d'Impots Générée24") { }

            column(Cout_Global24; "Cout Global24") { }

            column("Premier_Loyer_Majoré36"; "Premier Loyer Majoré36") { }

            column(Loyer36; Loyer36) { }

            column("Economie_d_Impots_Générée36"; "Economie d'Impots Générée36") { }

            column(Cout_Global36; "Cout Global36") { }


            column(Loyer48; Loyer48) { }

            column("Premier_Loyer_Majoré48"; "Premier Loyer Majoré48") { }

            column("Economie_d_Impots_Générée48"; "Economie d'Impots Générée48") { }

            column(Cout_Global48; "Cout Global48") { }

        }


    }


}

Here is the dialog box I would like to obtain in order to send my report by email to the client 

box-needed.png

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 570 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 390 Super User 2026 Season 2

#3
Teagen Boll Profile Picture

Teagen Boll 220 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans