我正在通過 sendgrid 和 nodejs 發送一些電子郵件。我有要發送的內容,但我無法添加如下所示的好正文
身體:
你好
您會收到這封電子郵件,提醒您輸入當天的時間。
最好的問候,運營團隊
我只能發送帶有訊息的郵件,但找不到添加“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);
uj5u.com熱心網友回復:
在純文本中,您可以添加換行符,它們將顯示在電子郵件中。請注意,您可以使用反引號 (`) 在 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);
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/465410.html
