我有我从收集用户输入一个TextArea()。
我想退了出去吐此输入电子邮件,但保存格式是很重要的。 如果有人提出在返回或段落分开他们的发言,我想,要在输出中反映出来。
目前,我有这个输入分配给一个变量,然后我引用该变量在MailApp()调用。 它不保存在这个过程格式:
var user_input=e.parameter.text_area_input;
MailApp.sendEmail({
to: "someemail@somedomain.com",
subject: "This is a subject.",
htmlBody: "Here is the text that was entered: <BR>" + user_input
})
我怎样才能做到这一点?
所以你需要更换新行字符“\ n”换行<BR>您发送HTML电子邮件。
以下是选项
//Send as text email
MailApp.sendEmail('someemail@somedomain.com',
'This is a subject',
'Here is the text that was entered: \n' + user_input);
//send as html email
MailApp.sendEmail('someemail@somedomain.com',
'This is a subject',
'', {htmlBody: 'Here is the text that was entered: <br>' + user_input.replace(/\n/g, '<br>')});
我没有测试的代码。 它可能有语法错误或拼写错误。