我需要帮助在脚本中添加空格或新行。它看起来像这样:
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});
}
我需要在"message.getPlainBody();"
"This email is sent from:" + " " + sender "
现在所有人都在电子邮件的同一行。是否有类似html标签<br>
?
答案 0 :(得分:1)
尝试添加\n
:
var body = "This email is sent from: " + sender + "\n" + message.getPlainBody();
答案 1 :(得分:1)
您可以在字符串中插入linebreak/newline个字符以开始新行。 请注意 \ n 实际上计为1个字符(\开始escape sequence)
var body = "This email is sent from:\n" + sender + "\n\n" + message.getPlainBody();