2

I have been trying to edit a script that I have to bold certain text. This script pulls information from a Google Form Spreadsheet and returns an email that looks like this:


Teacher Engagement: At initial observation, the teacher is appropriately engaged (Direct Instruction, Modeling, Constructing Knowledge, Guided/Independent Practice, etc.)

Technology Integration: No evidence of technology use or integration


I would like for the headers "Teacher Engagement:" & "Technology Integration" to be Bold and maybe underlined.How can I implement HTML into my code?

My code is:

function sendEmail() {

var sheet = SpreadsheetApp.getActiveSheet();

var row = sheet.getActiveRange().getRowIndex();

var userEmail = sheet.getRange(row,   
  getColIndexByName("Username")).getValue();

var body = "Below are the results of a recent Walkthrough: ";

 body += "\n\nTeacher Engagement: \n" + sheet.getRange(row,     
  getColIndexByName("Teacher Engagement")).getValue();

 body += "\n\nTechnology Integration: \n" + sheet.getRange(row,     
  getColIndexByName("Technology Integration")).getValue();

MailApp.sendEmail(userEmail, subject, body, {name:"Classroom Walkthrough"});
}
08Dc91wk
  • 4,254
  • 8
  • 34
  • 67
NR14
  • 45
  • 1
  • 6
  • see the official docs where it has a sample html email sent. try to convert the current string to html also as its currently not in that format. for example replace the "\n" with html paragraphs or just
    to keep it simple. give it a try first and update us wirh your results
    – Zig Mandel Jul 27 '15 at 22:56

1 Answers1

2

The only viable solution to format an E-mail with the MailApp is to use the HTMLbody option and to write your texte as HTML.

example :

function sendEmail() {

var sheet = SpreadsheetApp.getActiveSheet();

var row = sheet.getActiveRange().getRowIndex();

var userEmail = sheet.getRange(row,   
getColIndexByName("Username")).getValue();

var body = "<HTML><BODY>"
+"Below are the results of a recent Walkthrough: "
+"<P>Teacher Engagement: <BR>" 
+sheet.getRange(row,getColIndexByName("Teacher Engagement")).getValue()
+"</P>"
+"<P>Technology Integration: <BR>" 
+sheet.getRange(row,getColIndexByName("Technology Integration")).getValue()
+"</P></BODY></HTML>";

MailApp.sendEmail({
to:userEmail,
subject:subject,
htmlBody:body,
name:"Classroom Walkthrough"
});
}

result :

Below are the results of a recent Walkthrough: 

Teacher Engagement: 
stuff

Technology Integration: 
other stuff
  • Thanks Orange Bender! Your code worked, I just had to add to the areas I wanted to bold. The email ended up looking great and way easier to read. Thanks again. – NR14 Jul 28 '15 at 17:34