问题
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"});
}
回答1:
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
来源:https://stackoverflow.com/questions/31663006/how-do-i-format-my-text-in-google-script-for-it-to-show-when-i-send-an-email