One of the first tutorials I did when starting with Google Apps Script was the Simple Mail Merge tutorial. Since then some of the Google Apps Script top contributors guest posted 4 ways to do Mail Merge using Google Apps Script. Today when I was trying to solve my own html email problem I decided a solution that best fitted my needs was using a slight variation of the Simple Mail Merge but letting the user use wiki markup to format the text.
As well as sending the html email I wanted the old ‘having problems reading this email visit this online link’. To do this I published my spreadsheet as a service and built some basic UI Service wrapper and passed my wiki markup into a modified version of John Francis Workaround for HTML in Apps Script UIApp. Apps Script doesn’t allow you to chuck pieces of HTML markup at it and John’s code only turns paragraphs into text blocks. I needed inline hyperlinks as well so came up with this snippet which merges some of Remy Sharps code. I was going to take it further and add more wiki markup support for things like italics and bold but the InlineLabel escapes html (e.g. “ is rendered as " etc) so there didn’t seem to be a point.