如何在nodejs中的sendgrid api中添加好邮件
How to add a good email in sendgrid api in nodejs
我正在通过 sendgrid 和 nodejs 发送一些电子邮件。我有一个内容要发送,但我无法添加如下所示的正文
正文:
Hi
You are receiving this email as a reminder to enter time for the day.
Best Regards, Operations Team
我只能发送带有消息的邮件,找不到添加“此致,
运营团队”行。请提供见解。
我的代码,
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);
在纯文本中,您可以添加换行符,它们将显示在电子邮件中。请注意,您可以使用反引号 (`) 在 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);
我正在通过 sendgrid 和 nodejs 发送一些电子邮件。我有一个内容要发送,但我无法添加如下所示的正文
正文:
Hi
You are receiving this email as a reminder to enter time for the day.
Best Regards, Operations Team
我只能发送带有消息的邮件,找不到添加“此致, 运营团队”行。请提供见解。
我的代码,
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);
在纯文本中,您可以添加换行符,它们将显示在电子邮件中。请注意,您可以使用反引号 (`) 在 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);