How to attach a table structure in a mail in Business Central | CloudFronts

How to attach a table structure in a mail in Business Central


In this blog, I want to depict how a table structure can be integrated into an Email in Business Central using the HTML tags.

Pre-Requisites :

  1. Microsoft Dynamics 365 Business Central
  2. HTML


  1. Create an Email Structure using the SMTP Mail setup Codeunit and pages. The body that is to be attached to the Mail will be the table structure that will be created using HTML tags.
  2. The HTML tags used are as follows:

<th> : To create the heading for the table

<tr>: To create the rows for the table

<td>: To input the data for the table

Code for the table structure and mail is as follows:

SMTPSetup.CreateMessage('', SMTPMailSetup."User ID", Rec_Contact2."E-Mail", 'Scheduling Report', '', TRUE);
SMTPSetup.AppendBody('<table border="1">');
SMTPSetup.AppendBody('<th>Purchase Conformation</th>');
SMTPSetup.AppendBody('<th>Vendor Name</th>');
SMTPSetup.AppendBody('<th>Vendor Ref:</th>');
SMTPSetup.AppendBody('<th>Product Name</th>');
SMTPSetup.AppendBody('<th>Estimated PU Date</th>');
SMTPSetup.AppendBody('<th>PU Date</th>');
SMTPSetup.AppendBody('<th>PU Time Begin</th>');
SMTPSetup.AppendBody('<th>PU Time End</th>');
SMTPSetup.AppendBody('<td>' + Format("Blanket PO No.") + '-' + Format("Blanket PO Line No.") + '</td>');
SMTPSetup.AppendBody('<td>' + Format(Name) + '</td>');
SMTPSetup.AppendBody('<td>' + Format(VSO) + '</td>');
SMTPSetup.AppendBody('<td>' + Format(ProductName) + '</td>');
SMTPSetup.AppendBody('<td>' + Format(EstPUDate) + '</td>');
SMTPSetup.AppendBody('<td>' + Format(PUDate) + '</td>');
SMTPSetup.AppendBody('<td>' + Format(PUStartTime) + '</td>');
SMTPSetup.AppendBody('<td>' + Format(PUEndTime) + '</td>');

3) The table output looks as follows when the mail is sent:









Thus, using the basic HTML table tags a table structure can be integrated into the Email functionality of Business Central.

Share Story :

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.