我一直在寻找有关附件的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
我想念什么吗?感谢您的帮助!
我的数据已经是一个字符串,所以我不需要解析日期,我直接将其作为内容传递,然后就可以了。使用。csv和contentType:'text / csv'。来确保文件名。我希望这可以帮助某人遇到与我相同的问题。
const attachment =
`"test1,","test2,","test3,","test4"`
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'
},
};