如题,chooseMessageFile或者downloadFile获取到文件url,通过("nodemailer": "^6.7.3")发送邮件之后,在邮件里附件显示大小为0b,为啥呢?
(attachment传参path会失败,传filepath会成功,但附件是0b)
相关代码如下,有大佬解答下么,谢谢
wx.chooseMessageFile({
count: 1,
type: 'all',
success (res) {
let fileName = res.tempFiles[0].name
// 发送邮件
let attach = [{
filename:fileName,
filepath:res.tempFiles[0].path,
}]
that.sendMailWithAttach(attach)
app.uploadFile(res.tempFiles[0].path, 'test/' + fileName)then((filePath)=>{
app.downloadFile(filePath).then((res)=>{
wx.getFileSystemManager().saveFile({
tempFilePath: res.tempFilePath,
success(res){
console.log('下载完成',res.savedFilePath)
// 发送邮件
let attach = [{
filename:fileName,
filepath:res.savedFilePath,
}]
that.sendMailWithAttach(attach)
}
})
})
})
}
})
from: mail, // 发件人
subject: event.subject, // 主题
to: event.email=="" ? mail : event.email, // 收件人
text: event.text, // 邮件内容
html: event.html,
attachments: event.attachments,
};
nodemailer的附件参数,是要放附件的二进制内容的。文档读仔细了。