[英]How to add a good email in sendgrid api in nodejs
我正在通过 sendgrid 和 nodejs 发送一些电子邮件。 我有一个内容要发送,但我无法添加如下所示的正文
身体:
你好
您将收到此 email 作为输入当天时间的提醒。
最好的问候,运营团队
我只能发送带有消息的邮件,但找不到添加“此致,运营团队”行的方法。 请给一个见解。
我的代码,
sgmail.setApiKey(process.env.API_KEY);
const msg = {
to: '########', // Change to your recipient
from: "######", // Change to your verified sender
subject: `Reminder for Time Entry`,
text: "Hi You are recieving this email as a reminder to enter time for the day.",
html: "<h1> Hi You are recieving this email as a reminder to enter time for the day.</h1>",
}
sgmail.send(msg);
在纯文本中你可以添加换行符,它们将显示在email中。注意你可以使用反引号(`)在JavaScript中编写多行字符串。对于HTML电子邮件,你应该在不同的段落( <p>
)标签中换行. 尝试以下操作:
sgmail.setApiKey(process.env.API_KEY);
const textMessage = `Hi
You are receiving this email as a reminder to enter time for the day.
Best Regards, Operations Team`;
const htmlMessages = `<p>Hi</p>
<p>You are receiving this email as a reminder to enter time for the day.</p>
<p>Best Regards, Operations Team</p>`;
const msg = {
to: '########', // Change to your recipient
from: "######", // Change to your verified sender
subject: `Reminder for Time Entry`,
text: textMessage,
html: htmlMessage,
}
sgmail.send(msg);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.