我有一个 TextArea() ,我正在从中收集用户输入。
我想将此输入返回到电子邮件中,但保留格式很重要。如果有人输入返回或段落来分隔他们的陈述,我希望这能够反映在输出中。
目前,我将此输入分配给一个变量,然后在 MailApp() 调用中引用该变量。它不会通过此过程保留格式:
var user_input=e.parameter.text_area_input;
MailApp.sendEmail({
to: "[email protected]",
subject: "This is a subject.",
htmlBody: "Here is the text that was entered: <BR>" + user_input
})
我怎样才能做到这一点?
您正在发送一封 html 电子邮件,因此需要将换行符 '\n' 替换为换行符
。
这是选项
//Send as text email
MailApp.sendEmail('[email protected]',
'This is a subject',
'Here is the text that was entered: \n' + user_input);
//send as html email
MailApp.sendEmail('[email protected]',
'This is a subject',
'', {htmlBody: 'Here is the text that was entered: <br>' + user_input.replace(/\n/g, '<br>')});
我没有测试过代码。它可能有语法错误或拼写错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)