React生成带附件EML文件:附件在Outlook打开为空问题
带附件的EML文件在Outlook中附件内容为空问题
按照相关方案实现网页端带附件的EML文件生成功能后,下载的EML文件在Outlook中打开时,能看到附件条目且显示附件大小不为0,但点击打开附件后内容为空。
实现代码如下:
const makeOutlookFile = () => { const text = ` To: Demo-Recipient <demo@demo.example.com> Subject: EML with attachments X-Unsent: 1 Content-Type: multipart/mixed; boundary=boundary_text_string --boundary_text_string Content-Type: text/html; charset=UTF-8 <html> <body> <p>Example</p> </body> </html> --boundary_text_string Content-Type: application/octet-stream; name=demo.log Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="demo.log" aGVsbG8gd29ybGQ= --boundary_text_string--`; let textFile = null; var data = new Blob([text], { type: 'message/rfc822' }); textFile = window.URL.createObjectURL(data); let link = document.createElement("a"); link.href = textFile; link.target = "_blank"; link.download = ""; document.body.appendChild(link); link.click(); link.remove(); };
问题截图:
已搜索大量创建带附件EML文件的方案,大多与上述代码逻辑类似,但问题仍未解决。
内容的提问来源于stack exchange,提问作者RivkaZ
相关产品推荐
相关产品推荐

