如何使用JavaScript在eml中附加有效的XLSX文件

时间:2020-01-09 19:44:20

标签: javascript eml sheetjs

我尝试了以下多部分内容类型。稍后我将使用SheetJS附加一个excel文件。但是现在我无法附加有效的空白excel文件。任何帮助将不胜感激。

  let text =
        'To: User <user@domain.demo>\n' +
        'Subject: TW Order\n' +
        'X-Unsent: 1\n' +
        'Content-Type: multipart/mixed; boundary=--boundary_text_string\n\n' +
        '----boundary_text_string\n' +
        //'Content-Type:  application/application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; name=demo.xlsx\n' +
        'Content-Type: application/octet-stream; name=demo.xlsx\n' +
        'Content-Disposition: attachment;\n\n' +
        '----boundary_text_string--';

1 个答案:

答案 0 :(得分:0)

因此,为了将xlsx文件附加到eml,我们必须执行以下操作

 let text =
        'To: User <user@domain.demo>\n' +
        'Subject: TW Order\n' +
        'X-Unsent: 1\n' +
        'Content-Type: multipart/mixed; boundary=--boundary_text_string\n\n' +
        '----boundary_text_string\n' +
        'Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;\n' +
        'Content-Transfer-Encoding: base64\n'
        'Content-Disposition: inline; filename=a.xlsx\n\n' +
        'base64 data goes here\n\n'
        '----boundary_text_string--';