使用MailApp.sendEmail设置正文电子邮件文本格式的替代方法 [英] Alternatives to format text of body email using MailApp.sendEmail
问题描述
我有以下代码可以使用Google Apps脚本发送电子邮件:
I have this code to send emails with Google Apps Script:
var message = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua " + name + "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris" + receiver;
MailApp.sendEmail(email2Send, title, message);
但是发送给接收者的电子邮件没有格式,没有段落等.我至少会赞赏段落(新行),但是\ n不起作用.该文档告诉我:
But the email that goes to receiver has no formating, no paragraphs, etc. I would apreciate at least paragraphs (new lines) but \n doesn't work. The documentation tells me that:
htmlBody字符串(如果已设置),能够呈现HTML的设备将使用它而不是必需的body参数;您可以添加可选HTML正文中的inlineImages字段(如果您有内嵌图像)电子邮件
htmlBody String if set, devices capable of rendering HTML will use it instead of the required body argument; you can add an optional inlineImages field in HTML body if you have inlined images for your email
所以,我可以做这样的事情:
So, I could do something like this:
...
var options = {
htmlBody: '<b><i>TEST</i></b>'
};
MailApp.sendEmail('someone@domain.ext', 'TEST', 'TEST', options);
...
使用 MailApp.sendEmail
向邮件添加格式的替代方法有哪些?您能建议我一个简单的HTML模板转换为基本文本格式吗?(我想要比此(Gmail)从电子表格发送电子邮件.如何添加带有图像的签名?)
What are the alternatives do add format to a message using MailApp.sendEmail
? Could you suggest me one simple HTML templates to a basic text format? (I'd like something simpler than this (Gmail) Sending emails from spreadsheet. How to add signature with image?)
推荐答案
\ n
有效.
MailApp.sendEmail("myemailbox@example.sinvalid","test","multi\nline\ntext");
发送带有以下正文的邮件:
send a mail with the following body:
multi
line
text
这篇关于使用MailApp.sendEmail设置正文电子邮件文本格式的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!