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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Format a list of text to be sent over email body

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,708 Moderator on at

    Hi,

    I doubt this function 

    listData.GetRange(1,listData.Count)

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

    Thanks
  • Suggested answer
    AbhinavMehra Profile Picture
    364 on at

    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.

  • SammySevens Profile Picture
    130 on at

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

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

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 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans