【问题标题】:Sending mail of the html report from testcafe, how to achieve this?从testcafe发送html报告的邮件,如何实现?
【发布时间】:2019-11-25 15:19:12
【问题描述】:

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

【问题讨论】:

    标签: node.js testing report nodemailer testcafe


    【解决方案1】:

    您的 attachments 对象看起来不正确。使用path 属性而不是filepath

    attachments: [{
        filename: 'Report.html',
        path: '../test-reports/Report.html',
    }]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-07
      • 2019-04-17
      • 1970-01-01
      • 1970-01-01
      • 2017-06-17
      • 2019-07-03
      • 1970-01-01
      相关资源
      最近更新 更多