【发布时间】:2020-06-03 17:50:13
【问题描述】:
我一直在查看有关附件的 nodeMailer 文档,我遇到的问题需要发送如下所示的数据字符串,我需要将它们转换为 CSV,然后通过 nodeMailer 发送。
看到另一个数组到 CSV 的帖子,提到我需要在发送之前解析,所以我尝试使用 papaparse 数据并传入他们的自定义附件,但我会收到错误。
在节点中设置
const attachment =
""test1,","test2,","test3,","test4,""
const parseInfo = papaparse.parse(attachment, {delimiter: ",", newline: ""})
const options = {
to: toAddress,
from: fromAddress,
subject: subject,
text: text,
html: html,
attachments:{ // define custom content type for the attachment
filename: 'sample.csv',
content: parseData,
contentType: 'text/csv'
},
};
错误信息
An error occured while sending the email ---:TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer. Received type object
我错过了什么吗?感谢您的帮助!
【问题讨论】:
标签: javascript export-to-csv nodemailer papaparse