【发布时间】:2017-07-03 16:07:07
【问题描述】:
我正在尝试使用我在 Azure 上的 Node JS 应用程序发送电子邮件并收到此错误:
TypeError: sendgrid.Email is not a constructor
这是我的代码。我使用了来自 Microsoft (https://docs.microsoft.com/en-us/azure/store-sendgrid-nodejs-how-to-send-email) 的文档。
var sendgrid = require('sendgrid')('SendGrid User ID', 'SendGrid password');
function createEmail() {
console.log('CREATE EMAIL');
var emailToSend = new sendgrid.Email({
to: example@example.com,
from: 'example@example.com',
subject: 'Subject',
text: 'some text';
});
sendEmail(emailToSend);
}
function sendEmail(email) {
console.log('SEND EMAIL');
sendgrid.send(email, function (err, json) {
if (err) {
return console.error(err);
}
});
}
【问题讨论】:
-
看看这个:github.com/sendgrid/sendgrid-nodejs/issues/269 - 自从您链接的 MSDN 文章编写以来,SendGrid 节点支持似乎对其进行了重大更改。我链接的 GitHub 线程有一个更新代码示例的链接:sendgrid.com/docs/Integrate/Code_Examples/v3_Mail/nodejs.html