1
我只是想直接发送我的html文件,输入./blabla.html并且不创建广告系列或模板。有没有一种方法可以发送邮件而不需要添加嵌入的代码?如果是这样,我会非常高兴,谢谢! 我当前的代码如下所示:Sendgrid发送无需嵌入代码的HTML电子邮件
var helper = require('sendgrid').mail
from_email = new helper.Email("[email protected]")
to_email = new helper.Email("[email protected]")
subject = "Merhaba !"
content = new helper.Content("text/plain", "selam")
mail = new helper.Mail(from_email, subject, to_email, content)
}
var sg = require('sendgrid').SendGrid("mysecretapikey")
var requestBody = mail.toJSON()
var request = sg.emptyRequest()
request.method = 'POST'
request.path = '/v3/mail/send'
request.body = requestBody
sg.API(request, function (response) {
console.log(response.statusCode)
console.log(response.body)
console.log(response.headers)
})
为什么不能阅读HTML文件转换成字符串像这样:http://stackoverflow.com/questions/18386361/read-a-file-in-node-js?另外请注意,如果你想以HTML的形式发送,你会希望为'content'设置'text/html'。 –
没关系,但我无法找到放置该读取操作的位置。当我调用读取函数时,它只是读取cmd上的内容并将邮件发送给写入函数名称的接收方。任何帮助? @ Sebastian-LaurenţiuPlesciuc – MeganLondon