0
我试图发送一封电子邮件,在Azure上我的节点JS应用程序,并得到这个错误:SendGrid Azure的问题
TypeError: sendgrid.Email is not a constructor
这里是我的代码。我使用了微软的文档(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: [email protected],
from: '[email protected]',
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);
}
});
}
看看这个:https://github.com/sendgrid/sendgrid-nodejs/issues/269 - 它看起来像SendGrid节点支持已经有了突破性的改变,因为你链接的MSDN文章被写入。我链接的GitHub线程有一个更新代码示例的链接:https://sendgrid.com/docs/Integrate/Code_Examples/v3_Mail/nodejs.html –