how can I write multiline string google script
"Dear "+mailData.name+","+"Thank you for writing to us. We have received your message about "+mailData.subject+
" and will get back to you within 24 hours. Until then, you can give us an email [email protected]\n\n"+
"Thankyou \r "
You can create an html body instead. You also need to modify your MailApp.sendEmail() function to include htmlBody in the arguments.
Here is the solution:
var email_body =
`Dear ${mailData.name}, <br/>
Thank you for writing to us. We have received your message about ${mailData.subject}. <br/>
and will get back to you within 24 hours. Until then, you can give us an email [email protected]. <br/>
Thank you <br/><br/>`
MailApp.sendEmail( {to:mailData.email, subject:mailData.subject, body:email_body,htmlBody:email_body}); // subject
Note that <br/><br/>
will generate two new lines and <br/>
will generate one.
Read more information regarding Template literals here.