Create custom email to send using SendGrid

Using SendGrid in a test, I am creating (and successfully sending) an email requesting a price quote. So far successfully sending the quote to myself, but eventually it will go to site visitors upon request.

The email in about 100 words plus the actual quote in “table” form. The only way I know to build this using code is to create a “huge” string containing the email words and tabbed table data. The email looks good but the table is very difficult to get the columns lined up since string tabbing is very simplistic. Actually it is impossible to get this looking good since the text of the dollar figures and the potentially the fonts change.

Below I show how I built my email and table. Is there a way to build the table using some other method than with strings?

Thanks and I hope you have enough information to give me some ideas.

The text string is formulated in a single element array, where I use the “push” method to append text strings onto the array. This works and is fast, but the “simulated” table does not look good since can;t right justify using strings. Snippets from my code look like this:

**let**  hdr  = [] 

//The email uses a Template String, a special type of string that can have variables in them. 
hdr . push  ( `Subject: Your Confirmation Email        [ ${ serialNumber } ] 

Dear ${ cap($w ( “#firstName” ). value )} ${ cap($w ( “#lastName” ). value )} ,

Thank you very much for requesting a written quotation.  
We expect to issue via email within one day. 

etc,
etc,
etc.

The table data is also pushed onto the array. What is pushed depends on the length of the price I am pushing. Doing this to try to line up the columns.

if ( results.items[i ]. price.length <= 4 && results.items[i ]. sku.length <= 9 ) {
hdr . push ( \n\tPrice: ${ results.items[i ]. price } \t\t( ${ results.items[i ]. sku } )\t\t\t ${ results.items[i ]. productName . trim ()} , ${ results.items[i ]. variants . trim ()} )
} else if ( results.items[i ]. price.length <= 4 && results.items[i ]. sku.length <= 12 ) {
hdr . push ( \n\tPrice: ${ results.items[i ]. price } \t( ${ results.items[i ]. sku } )\t\t\t ${ results.items[i ]. productName . trim ()} , ${ results.items[i ]. variants . trim ()} )
} else if ( results.items[i ]. price.length <= 5 && results.items[i ]. sku.length <= 7 ) {
hdr . push ( \n\tPrice: ${ results.items[i ]. price } \t( ${ results.items[i ]. sku } )\t\t\t\t ${ results.items[i ]. productName . trim ()} , ${ results.items[i ]. variants . trim ()} )
} else if ( results.items[i ]. price.length <= 5 && results.items[i ]. sku.length <= 9 ) {

etc,
etc,
etc.