【问题标题】:How to write newline in google script如何在谷歌脚本中编写换行符
【发布时间】:2020-11-30 00:00:55
【问题描述】:
如何编写多行字符串谷歌脚本
"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 sm@g.com\n\n"+
"Thankyou \r "
【问题讨论】:
标签:
google-apps-script
google-sheets
gmail-api
template-literals
【解决方案1】:
您可以改为创建一个 html 正文。您还需要修改 MailApp.sendEmail() 函数以在参数中包含 htmlBody。
解决办法如下:
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 sm@g.com. <br/>
Thank you <br/><br/>`
MailApp.sendEmail( {to:mailData.email, subject:mailData.subject, body:email_body,htmlBody:email_body}); // subject
请注意,<br/><br/> 将生成两个新行,<br/> 将生成一个。
阅读有关模板文字here 的更多信息。