将文本插入带有来自其他文件的函数的html/css电子邮件中
我有一个HTML/CSS电子邮件模板,我想用它来向用户发送电子邮件,例如在注册,发送秘密代码和通用电子邮件之后欢迎的内容。
我需要用自定义文本“注入”此HTML模板,而不是当前包含的lorem ipsum。
我想制作一个JavaScript函数,将给定文本插入我的HTML模板中,这样我的电子邮件服务可以根据用户在我的节点应用程序中根据其电子邮件和自定义消息发送自定义电子邮件,因为某些事件被触发。
我在文件 generalcontact.html 中有一个html/css电子邮件,
我不确定 1 如何“导出”它,以便makeemail.js可以访问模板和模板和模板 2 如何格式化HTML电子邮件,以便它可以接受自定义输入文本。
我必须以某种方式将模板分配给变量吗?
任何帮助/指导将不胜感激,谢谢。
makeemail.js
const htmlTemplate = require("generalContact.html")
const makeEmail = (bodyText) => {
// How can I access the HTML file and insert the above input into it?
return emailWithTextInserted
}
module.exports = makeEmail
GeneralContact.html
<!DOCTYPE html PUBLIC "-//W3C/...." "http://www.w3.org/.....">
<html xmlns="http://www.w3.org......">
<head>
<title></title>
</head>
<body>
<center>
<tr>
<td>
This is Photoshop's version of Lorem Ipsum. Proin gravida nibh vel
velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor,
nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis
<a>
sit amet nibh vulputate cursus a sit amet mauris.<br /><br />
Mauris in erat justo. Nullam ac urna eu felis dapibus condimentum sit
amet a augue. Sed non neque elit. Sed ut imperdiet nisi. Proin
condimentum fermentum nunc. Etiam
<a>
erat sed fermentum feugiat, velit mauris egestas quam, ut aliquam
massa nisl quis neque. Suspendisse in orci enim.
</td>
</tr>
</center>
</body>
</html>
I have a html/css e-mail template that I want to use to send users e-mails for things like welcoming after signing up, send secret codes, and general purpose e-mails.
I need to "inject" this html template it with custom text instead of the lorem ipsum it currently contains.
I want to make a javascript function that inserts given text into my html template, this way my e-mail service can send custom e-mail to users based on their e-mail and custom messages throughout my node app as certain events are triggered.
I have a html/css e-mail in the file generalContact.html
I am unsure of 1 how "export" it so that makeEmail.js has access to the template and 2 how to format the html email so it can accept custom input text.
Do I have to assign the template to a variable first somehow?
Any help/guidance would be appreciated, thank you.
makeEmail.js
const htmlTemplate = require("generalContact.html")
const makeEmail = (bodyText) => {
// How can I access the HTML file and insert the above input into it?
return emailWithTextInserted
}
module.exports = makeEmail
generalContact.html
<!DOCTYPE html PUBLIC "-//W3C/...." "http://www.w3.org/.....">
<html xmlns="http://www.w3.org......">
<head>
<title></title>
</head>
<body>
<center>
<tr>
<td>
This is Photoshop's version of Lorem Ipsum. Proin gravida nibh vel
velit auctor aliquet. Aenean sollicitudin, lorem quis bibendum auctor,
nisi elit consequat ipsum, nec sagittis sem nibh id elit. Duis
<a>
sit amet nibh vulputate cursus a sit amet mauris.<br /><br />
Mauris in erat justo. Nullam ac urna eu felis dapibus condimentum sit
amet a augue. Sed non neque elit. Sed ut imperdiet nisi. Proin
condimentum fermentum nunc. Etiam
<a>
erat sed fermentum feugiat, velit mauris egestas quam, ut aliquam
massa nisl quis neque. Suspendisse in orci enim.
</td>
</tr>
</center>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将GeneralContact.html a .js文件制作,或者将其放入当前.JS文件中,则可以使整个HTML平板一个变量使整个HTML平板一个变量。
然后在用户添加了与事件的内容添加该内容后更新customInputText变量。
此时,您可以使用html.latest检索更新的HTML
If you instead make the generalContact.html a .js file, or just put it in the current .js file, then you can make the whole HTML slab one variable.
Then update the customInputText variable after the user has added that content with an event.
At this point, you can retrieve the updated HTML using HTML.latest