Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

How yo print notes on email body

Posted on by 200

Here I have email body where I need note printed,

procedure SendEmail(oldno: Record Enquiries; newno: Code[20])

    var

        cdu_EmailMessage: Codeunit "Email Message";

        cdu_Email: Codeunit Email;

        ToRecipients: Text;

        Subject: Text;

        Body, AddBody : Text;

        textWorkDes: Text[100];

        enum_RecipientType: Enum "Email Recipient Type";

        rec_enquries: Record Enquiries;

        rec_salesheader: Record "Sales Header";

        enum_DocumentType: Enum "Sales Document Type";

        enum_Alerts: Enum Alerts;

        SalesPostedMsg: Label '<br> The initial SalesOrder Number is <strong>%1</strong>. <br>The Replacement SalesOrder Number is <strong>%2</strong>. <br> The Note is <strong>%3</strong>';

    begin

        Subject := 'Enquries';

        Body := StrSubstNo(SalesPostedMsg, oldno.No, newno, oldno.Note);

        Body += '<br><br>Kind Regards,<br><br>Business Central';

       cdu_EmailMessage.Create(cdu_CommonHelper.EmailSetup(enum_Alerts::"EnquiriesAndReturns"), Subject, Body, true);

        if rec_enquries.Count > 0 then begin

            cdu_Email.Send(cdu_EmailMessage);

            //rec_enquries.DeleteAll(); end;

        end;

    end;

With this code my notes entered in input box is coming now,

The-notes-module.png

But I want,

2845.Screenshot_5F00_1.png

I want this note Test1 which I got using copylinks function to be printed in my mail how can do that please help

  • Suggested answer
    Tech-Lucky Profile Picture
    Tech-Lucky 796 on at
    RE: How yo print notes on email body

    sorry please add RecordLink.Calcfields(Note); after repeat: i have modified the Previous code you can check.

  • Dividutt Profile Picture
    Dividutt 200 on at
    RE: How yo print notes on email body

    Hi, Thanks for this, but I have a question that Notes data type is blob so whether I need to convert it? Because still I was getting note blank in my email body

  • Suggested answer
    Tech-Lucky Profile Picture
    Tech-Lucky 796 on at
    RE: How yo print notes on email body

    Create the below function and call the function in your code remember to fetch the SalesHeader Record variable to pass it as a parameter and store the return value of the function to a Variable and place that variable in your Email Body as per your requirement.

        Procedure GetNotes(Var SalesHeader: Record "Sales Header") AllNotes: Text
        Var
            RecordLink: Record "Record Link";
            RecordLinkMangt: Codeunit "Record Link Management";
        Begin
            RecordLink.Reset();
            RecordLink.Setrange("Record ID", SalesHeader.RecordID);
            RecordLink.Setrange(Type, RecordLink.Type::Note);
            IF RecordLink.Findset Then
                Repeat
                    RecordLink.Calcfields(Note);
                    IF AllNotes = '' then
                        AllNotes := RecordLinkMangt.ReadNote(RecordLink)
                    else
                        AllNotes := AllNotes   ', '   RecordLinkMangt.ReadNote(RecordLink);
                Until RecordLink.Next() = 0;
    
        end;

    mark my answer varified if this helps you.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans