Skip to main content

Notifications

Announcements

No record found.

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

Format a list of text to be sent over email body

Posted on by 130

Hi BC Community,

I would like to email an entire POs lines to a user. 

I can populate a list to include all lines, however, I can not figure out how to email this list using strsubstno.

The current issue is that even though I include the listdata variable into the StrSubstNo function, in AddBodyMessage that element is blank, and subsequent email text is blank. 

My code below:

if userEmail <> '' then begin
    purchaseLine.SetRange(purchaseLine."Document Type", PurchaseHeader."Document Type");
    purchaseLine.SetRange(purchaseLine."Document No.", PurchaseHeader."No.");
    
    if purchaseLine.FindSet() then begin
        repeat
            listData.Add(purchaseLine.Description);
            counter := counter   1;
        until purchaseLine.next = 0;
        end;
    
    BodyMessage := 'Dear %1,
%2 has been fully approved.
Vendor:%3
Total($):%4
%5'; subjectMessage := 'Your request %1 has been fully approved'; AddBodyMessage := StrSubstNo(BodyMessage, userName, purchaseHeader."No.", purchaseHeader."Buy-from Vendor Name", purchaseHeader.Amount, listData.GetRange(1,listData.Count)); addUserSubject := StrSubstNo(subjectMessage, purchaseHeader."No."); EmailMessage.Create(userEmail, addUserSubject, AddBodyMessage, true);

Thanks as always

  • SammySevens Profile Picture
    SammySevens 130 on at
    RE: Format a list of text to be sent over email body

    Yes am aware of this, and debugger indicates that listData[1][2][x...] elements are populated with a string.

    So listData is not empty, but body message does not print out its contents, so I am also sure that is the source of the problem, but not sure how to remedy...

  • Suggested answer
    AbhinavMehra Profile Picture
    AbhinavMehra 364 on at
    RE: Format a list of text to be sent over email body

    Hi Sammy,

    The listData variable is added to the email message using the GetRange method, but it's not clear how the listData variable is being populated. It's possible that the listData variable is empty.

    you have to debugger to test value in Listdata variable first.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Format a list of text to be sent over email body

    Hi,

    I doubt this function 

    listData.GetRange(1,listData.Count)

    I dont think it returns and values you want. Can you check this?

    Thanks

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!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans