gpt4 book ai didi

node.js - 从testcafe发送html报告的邮件,如何实现?

转载 作者:行者123 更新时间:2023-11-28 21:03:26 24 4
gpt4 key购买 nike

您好,我正在为我的项目使用开源 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com