Adding Line Breaks to my code

505 views
Skip to first unread message

Carlin Hatcher

unread,
Jul 3, 2019, 9:38:32 AM7/3/19
to Google Apps Script Community
Good Morning,

I've been working on an MailApp.sendEmail function and it works fine, but I can't quite figure out how to add in line breaks. I've tried using ("/n") , (+)and (+ "/n"), but no success. Any assistance would be helpful. Here is my script:

function Driver_Selected_1(){
  var recipients = "na...@blue.com"
  var name = "My Name"
  var body = name 
           + "A driver has been selected." 
           + "Please view the following spreadsheet"
           +  "link to google sheet"
  
  MailApp.sendEmail(recipients,"Supervisor - 1st Shift",body)
}

Andrew Roberts

unread,
Jul 3, 2019, 10:56:58 AM7/3/19
to Google Apps Script Community
Put you slashes the other way:

var body = name + ",\n" + 
           + "A driver has been selected.\n" 
           + "Please view the following spreadsheet\n"
           +  "link to google sheet"

Carlin Hatcher

unread,
Jul 3, 2019, 12:50:13 PM7/3/19
to Google Apps Script Community
Wow, can't believe I didn't catch that. Thanks Andrew! Everything is working as it should.

IAlex

unread,
Jul 8, 2019, 11:40:02 PM7/8/19
to Google Apps Script Community
Hi Carlin!

Frequently used

  var body = [
    name
,
   
"A driver has been selected.",
   
"Please view the following spreadsheet",
   
"link to google sheet"
 
].join("\n");
Reply all
Reply to author
Forward
0 new messages