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

Notifications

Announcements

Community site session details

Community site session details

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

Sending Customer Mails

(1) ShareShare
ReportReport
Posted on by
Hi All,

I have made a custom report on the sales price list (Price List Header 7000). I want to send this price list to all customers separately that are linked to this price list (The same way that the customer statements are being sent out). However when click on the new button the report is being printed instead of being emailed. The price lists are setup on customer price groups and all customers linked to this group (there are multiple groups but a customer can only belong to one group) must receive separate emails with their report.

This is my Action for the button:
            action(APTPVC_SendPriceList)
            {
                Caption = '&Send Email ';
                Image = Email;
                Ellipsis = true;
                ToolTip = 'Prepare to send the Sales Price Lists. A report request window for the document opens where you can specify what to include on the email.';
                Promoted = true;
                PromotedCategory = Report;
                trigger OnAction()
                var
                    PriceListLine: Record "Price List Line";
                    CustomReportSelection: Record "Custom Report Selection";
                    CustomLayoutReporting: Codeunit "Custom Layout Reporting";
                    RecRef: RecordRef;
                begin
                    RecRef.Open(Database::"Price List Line");
                    CustomLayoutReporting.SetOutputFileBaseName(StatementFileNameTxt);
                    CustomReportSelection.SetRange(Usage, "Report Selection Usage"::"S.PriceList");
                    if CustomReportSelection.FindFirst() then
                        CustomLayoutReporting.SetTableFilterForReportID(CustomReportSelection."Report ID", PriceListLine."Assign-to No.")
                    else
                        CustomLayoutReporting.SetTableFilterForReportID(Report::APTPVC_SalesPriceList, PriceListLine."Assign-to No.");
                    CustomLayoutReporting.ProcessReportData(
                        "Report Selection Usage"::"S.PriceList", RecRef, PriceListLine.FieldName("Assign-to No."),
                        Database::"Price List Line", PriceListLine.FieldName("Assign-to No."), true);
                end;
            }
 
And this is my report output option:
 group("Output Options")
                {
                    Caption = 'Output Options';
                    field(ReportOutput; SupportedOutputMethod)
                    {
                        ApplicationArea = Basic, Suite;
                        Caption = 'Report Output';
                        OptionCaption = 'Email';
                        ToolTip = 'Specifies the output of the scheduled report.';
 
                        trigger OnValidate()
                        var
                            CustomLayoutReporting: Codeunit "Custom Layout Reporting";
                        begin
                            case SupportedOutputMethod of
                                SupportedOutputMethod::Email:
                                    ChosenOutputMethod := CustomLayoutReporting.GetEmailOption();
                            end;
                        end;
                        // local procedure SetReportInboxOutputTypeForPrint(var ReportInbox: Record "Report Inbox"; ReportID: Integer) (DEFAULTS TO PDF)
                    }
 
Is there something I have missed? Or perhaps not linking correctly that causes the emails not to send? The report is printing correctly.

Thanks
Divan
 
 
I have the same question (0)
  • Suggested answer
    Dynamics_Decoded_Gokul Profile Picture
    478 on at
    Hi, 

    In the above i am unable to find the Email templates attached Please use the below and you can customize your requirement with that 
     
     trigger OnAction()
                    var
                        TempEmailItem: Record "Email Item" temporary;
                        EmailScenario: Enum "Email Scenario";
                    begin
                        TempEmailItem.AddSourceDocument(Database::Customer, Rec.SystemId);
                        TempEmailitem."Send to" := Rec."E-Mail";
                        TempEmailItem.Send(false, EmailScenario::Default);
                    end;
  • Dynamics_Decoded_Gokul Profile Picture
    478 on at
    Hi, 

    In the above i am unable to find the Email templates attached Please use the below and you can customize your requirement with that 
     
     trigger OnAction()
                    var
                        TempEmailItem: Record "Email Item" temporary;
                        EmailScenario: Enum "Email Scenario";
                    begin
                        TempEmailItem.AddSourceDocument(Database::Customer, Rec.SystemId);
                        TempEmailitem."Send to" := Rec."E-Mail";
                        TempEmailItem.Send(false, EmailScenario::Default);
                    end;

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,585

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 780 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 712 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans