Data alignment in emails

60 views
Skip to first unread message

Fred Swartz

unread,
Jun 18, 2024, 4:03:35 PM (11 days ago) Jun 18
to google-apps-sc...@googlegroups.com

Greetings Apps Script Community, 

I want to align data in three columns in emails to be sent to my group.  I have varying string lengths for columns [1] and [12].  Data in [13] is a single digit.  
    Column 1, selected Olympic Sports, currently has content lengths varying from 9 to 23 characters. 
                    It would be fine to make this field 25 characters in length. 
    Column 2, Predicted Medalist Countries, has possible variation from 4 to 27 characters.  
                    I can make it work with, say, 10 characters.  
    Column 3, Points Earned, will be a single digit (5,3,1,0), awarded if the predicted country earns a medal. 

For Columns 1 and 2, should string lengths be standardized before launching the Send GmailApp.sendEmail(respDataPicks[25][12], subject, strBody); 
If so, how?
Or, can Gmail use fields to be populated in order to get organized output.  If so, how?

Obviously, I'm floundering and not finding the key to this problem.

Thanks in advance.

Fred

// Send to FS...Fred
msgGreeting = ("Hello FS..Fred " + "\n" + "\n");
for ( iRow = 7; iRow <= 22; iRow++) {
detailLine = (respDataPicks[iRow][1] + " " + respDataPicks[iRow][12] + " " + respDataPicks[iRow] [13] +"\n" );
msgDetail = msgDetail+ detailLine;
}
Logger.log (msgDetail );
strBody = strBody.concat(msgGreeting,msgIntro, msgDetail);

GmailApp.sendEmail(respDataPicks[25][12], subject, strBody);

}

George Ghanem

unread,
Jun 19, 2024, 1:30:05 PM (10 days ago) Jun 19
to google-apps-sc...@googlegroups.com
Hi Fred,

I would suggest using HTML formatting for the email and use table to place your data. That would ensure they are aligned.


--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/CANKtDPuO4pBw455ettfoVLWh4R%3Dg4FaL%3Dk8hNMDSQNHohJP3Ag%40mail.gmail.com.

Fred Swartz

unread,
Jun 19, 2024, 5:19:25 PM (10 days ago) Jun 19
to Google Apps Script Community
Thank you for the suggestion.  I won't have sufficient time to meet the HTML challenge.  Is it possible to create a "work-around" with Google Docs...load a Document with my Apps Script text and the load my three-column table into a Docs three-column table...then attach the Document via the GmailApp.sendEmail method?  If so, where would I find a useful source for this task of articulating between the Gmail and Documents tools?   Firing in the dark here.....

Thanks,

Fred

George Ghanem

unread,
Jun 19, 2024, 11:51:29 PM (9 days ago) Jun 19
to google-apps-sc...@googlegroups.com
I can put together a little function that does this.

Can you share a sample spreadsheet that has some sample data that you want to appear in the email body and give me edit access to it?

Reply all
Reply to author
Forward
0 new messages