You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 18:59:54