node.js - NodeJS params.Example 未被@sendgrid/mail 使用
问题描述
Watson Assistant 正确传递了我的 params.finalemail 和 params.gustemail。看起来您的 @sendgrid/mail 不接受这些参数的值。这是为什么?
基本上,Watson 将 $guest 电子邮件作为“收件人”电子邮件地址传递,而 $finalemail 包含电子邮件的主体。
我需要我的函数来发送一封电子邮件,其中包含上述变量中包含的信息。
const sgMail = require('@sendgrid/mail');
/* Replace YOUR-SENDGRID-API-KEY-GOES-HERE with
the API Key you get from SendGrid.
*/
sgMail.setApiKey('apikey')
function sendmail(params) {
params.guestemail
params.finalemail
let msg = {}
msg.to = params.guestemail
msg.from = 'example@outlook.com'
msg.subject = 'Your Reservation'
msg.html = params.finalemail
sgMail.send(msg,(error, json) => {
if (error) {
console.log(error)
}
})
return { sent: 1 }
}
解决方案
Sendgrid 将发送文本字段或 html,而不是两者。要发送您想要的消息,您可以添加“此消息仅是 HTML”。在 html 标记中。
推荐阅读
- node.js - MongoDB - 我如何创建索引有什么问题?
- visual-studio - 如何在visual studio ide扩展定制中调用自定义函数?
- java - Java:从零舍入的函数?
- python - Keras 在优化器中更新损失值
- ssl-certificate - haproxy 能够添加客户端 ssl 证书吗?
- python-3.x - 如何初始化具有特定维度的空张量并通过循环附加到它而没有 CUDA 内存不足?
- php - 在函数中传递默认参数值不起作用
- c# - 在camelCase中序列化存储C#类
- adobe - 窗口菜单扩展中的 Adobe Premier Pro 未显示/禁用...?
- python-sphinx - 在 sphinx doc 中运行的 doctest