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

How to attach a valid XLSX file in eml using JavaScript

我尝试了以下多部分内容类型。稍后我将使用 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--';

因此,为了将 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--';