Skip to main content

Notifications

Announcements

No record found.

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

  • T_Mauser Profile Picture
    T_Mauser 397 User Group Leader on at
    RE: Add Email Action to a Page

    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

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 75,561 Super User 2024 Season 2 on at
    RE: Add Email Action to a Page

    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
    T_Mauser 397 User Group Leader on at
    RE: Add Email Action to a Page

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

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,561 Super User 2024 Season 2 on at
    RE: Add Email Action to a Page

    Hi, I think the following blog can help you.

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

    Thanks.
    ZHU

  • Suggested answer
    Stefan Sosic Profile Picture
    Stefan Sosic 35 on at
    RE: Add Email Action to a Page

    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.

  • T_Mauser Profile Picture
    T_Mauser 397 User Group Leader on at
    RE: Add Email Action to a Page

    pastedimage1658848652194v1.png

    Like inside the Sales Quote page...

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

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,602 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,340 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans