向输出空间或新行添加新行或空格



我需要帮助在脚本中添加空间或新行。它看起来像这样:

function myFunction() {
 var firstThread = GmailApp.getInboxThreads(0,1)[0];
 var message = firstThread.getMessages()[0];
 var sender = message.getFrom();
 var body = "This email is sent from:" + " " + sender + message.getPlainBody();
 var subject = message.getSubject();
 var attachment = message.getAttachments();
 GmailApp.sendEmail("user.name@aruba.com", subject, body, {attachments: attachment});
}

我需要在"This email is sent from:" + " " + sender "

下面的新行添加"message.getPlainBody();"

现在都在Email的同一行。是否有类似的东西像html标签<br> ?

您可以在字符串中插入换行/换行字符以开始新的行。注意n,它实际上算作1个字符(开始一个转义序列)

var body = "This email is sent from:n" + sender + "nn" + message.getPlainBody();

试着添加n:

var body = "This email is sent from: " + sender + "n" + message.getPlainBody();

最新更新