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

Add Email Action to a Page

(0) ShareShare
ReportReport
Posted on by 397 User Group Leader

Hello,

I want to add an Email-Action to the Blanket Order Page.

I know how to add such actions, thats not the problem but what is the right logic for the "onAction" trigger to run the Email Dialog

set the subject

set the attachment (report)

set the mail text (report)

Does anyone have some refernces or docs about that?

Blanket Order Page Ext.

        addbefore(AttachAsPDF)
        {
            action(Email)
            {
                ApplicationArea = Basic, Suite;
                Caption = 'Senden per Email';
                Ellipsis = true;
                Image = Email;
                Promoted = true;
                PromotedCategory = Category6;
                PromotedIsBig = true;
                ToolTip = 'Prepare to mail the document. The Send Email window opens prefilled with the customer''s email address so you can add or edit information.';

                trigger OnAction()
                var
                    SalesHeader: Record "Sales Header";
                begin
                    SalesHeader := Rec;
                end;

Tom

I have the same question (0)
  • T_Mauser Profile Picture
    397 User Group Leader on at

    pastedimage1658848652194v1.png

    Like inside the Sales Quote page...

    But it is not allowed to use DocPrint.EmailSalesHeader(Rec); WHY not?

  • Suggested answer
    Stefan Sosic Profile Picture
    35 on at

    Which BC version is it?

    Since, [Obsolete('Email dialog has been removed, event no longer relevant.', '20.0')

    You could use  O365SalesEmailDialog: Page "O365 Sales Email Dialog";

    Example:

      TempEmailItem.Subject := EmailSubject;
            TempEmailItem.SetBodyText(EmailBody);
            TempEmailItem."Send to" := EmailAddress;
            TempEmailItem.AddCcBcc();
            TempEmailItem.AttachIncomingDocuments(DocumentNo);
            TempEmailItem.Insert(true);
            Commit();
    
            O365SalesEmailDialog.SetValues(DocumentRecordVariant, TempEmailItem);
            if DocumentType = DocumentType::Quote then
                O365SalesEmailDialog.SetNameEstimate
            else
                O365SalesEmailDialog.SetNameInvoice;
            HasBeenSent := O365SalesEmailDialog.RunModal = ACTION::OK;
    
            O365SalesEmailDialog.GetRecord(TempEmailItem);

    Edit:

        var
            DocumentPrint: Codeunit "Document-Print";
            SalesHeader: Record "Sales Header";
        begin
            DocumentPrint.EmailSalesHeader(SalesHeader);
    How do you mean its not allowed?

    Don't forget to help the community by verifying the answer or at least like the suggestion if it did help in any way. It will let others know that the topic has verified answer and was beneficial to you.

  • Suggested answer
    YUN ZHU Profile Picture
    96,175 Super User 2025 Season 2 on at

    Hi, I think the following blog can help you.

    https://simplanova.com/blog/dynamics-365-business-central-email-and-email-message-basics/

    Thanks.
    ZHU

  • T_Mauser Profile Picture
    397 User Group Leader on at

    Stefan Sosic

    I'm using BC in the cloud ->20.3.42673.42776

    yzhums

    Hmm... I would like to generate the email body and the attachment from a report.

    Do you know if it's possible with DocumentSendingProfile.TrySendToEMail() ? I didn't get it running...

  • Verified answer
    YUN ZHU Profile Picture
    96,175 Super User 2025 Season 2 on at

    Hi, is it possible to give Word Template a try?

    https://docs.microsoft.com/en-us/dynamics365-release-plan/2021wave2/smb/dynamics365-business-central/send-mail-entities-using-word-templates-as-body-or-attachment

    https://yzhums.com/19955/

    You can use Word Template to create Email Body, and then use Codeunit "Email Message" to add attachments.

    Hope this can give you some hints.

    Thanks.

    ZHU

  • T_Mauser Profile Picture
    397 User Group Leader on at

    Hello yzhums , it's working thank you.

    in the end the solution with the word template is better, because of it's flexibility which was needed in that case.

    Greetings,

    Tom

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,742

#2
YUN ZHU Profile Picture

YUN ZHU 844 Super User 2025 Season 2

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 719 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans