您好,我正在为我的项目使用开源 testcafe(不是工作室),一旦我的 testcafe 测试运行,它就会创建一个 testrail-html 报告。现在我想通过电子邮件发送我收到的报告。我怎么做。我已经使用 nodemailer 并在一定程度上实现了这一点,邮件正在发送时附有报告,但是附加到邮件的 html 报告显示为空白,请你帮忙。
var mailer = require("nodemailer");
var smtpTransport = require('nodemailer-smtp-transport');
var transporter = mailer.createTransport(smtpTransport({
host: 'mailo2.abc.com',
}));
// send mail with defined transport object
var mail = {
from: '<john.doe@abc.com>', // sender address
to: "<john.doe@abc.com>'// list of receivers
subject: "Report for ABC Vital Business Function", // Subject line
html: "<b> ABC Vital Business Function Report Attached</b>", // html body
attachments: [{
filename: 'Report.html,
filepath:'.. /test-reports',
}]
}
transporter.sendMail(mail, function(error, response){
if(error){
console.log(error);
}else{
console.log("Message sent: " + response.message);
}
transporter.close();
});
最佳答案
您的附件
对象看起来不正确。使用 path
属性而不是 filepath
:
attachments: [{
filename: 'Report.html',
path: '../test-reports/Report.html',
}]
关于node.js - 从testcafe发送html报告的邮件,如何实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59034964/