为什么 CSV 附件会在正文中显示为文本?

发布于 2024-08-30 13:56:28 字数 298 浏览 2 评论 0原文

我刚刚实现了一些代码,通过电子邮件向我们的一群客户发送 CSV 文件附件。

有些人(不多)回复我们抱怨说他们根本没有收到附件,只有电子邮件正文中的 CSV 文本。不过大多数都很好。

我怀疑不同的邮件客户端以不同的方式处理附件,但我还没有足够的信息来确定。

我使用 .NET 的 MailMessage 类和 Attachment.CreateAttachmentFromString() 方法。我为附件指定的 MIME 类型是 text/csv。

有人知道到底发生了什么事吗?

大卫

I've just implemented some code that emails a bunch of our clients with a CSV file attachment.

Some (not many) have got back to us complaining that they don't get an attachment at all - just the CSV text inside the body of the email. Most however are fine.

I suspect that it's different mail clients that are treating the attachment differently but I don't have enough info yet to be sure.

I'm using .NET's MailMessage class with the Attachment.CreateAttachmentFromString() method. The MIME type I'm specifying for the attachment is text/csv.

Anyone have any idea what the heck is going on?

Ta muchly

David

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

转身泪倾城 2024-09-06 13:56:28

另一种可能性是,失败的电子邮件客户端无法识别 MIME 类型“text/csv”,因此会显示未内嵌解释的内容——实际上,它可能会以“text/plain”的形式表现得更好。


编辑:我刚刚从 Outlook 向我的 Gmail 发送了一条带有 CSV 附件的测试邮件,并使用菜单选项“显示原始内容”来查看实际的多部分内容,这就是我所看到的:

Content-Type: application/octet-stream; name="test.csv"
Content-Description: test.csv
Content-Disposition: attachment;
  filename="test.csv";
  size=44;
  creation-date="Wed, 28 Apr 2010 14:13:20 GMT";
  modification-date="Wed, 28 Apr 2010 14:13:43 GMT"
Content-Transfer-Encoding: base64

所以看起来 'application/octet-stream' 可以解决问题。

Another possibility is that the failing email clients do not recognize the MIME type 'text/csv' and thus are showing the content uninterpretted in-line -- it may actually go through better as 'text/plain'.


Edit: I just sent a test message with a CSV attachment from Outlook to my Gmail, and used the menu option "Show original" to see the actual multi-part content, and this is what I see:

Content-Type: application/octet-stream; name="test.csv"
Content-Description: test.csv
Content-Disposition: attachment;
  filename="test.csv";
  size=44;
  creation-date="Wed, 28 Apr 2010 14:13:20 GMT";
  modification-date="Wed, 28 Apr 2010 14:13:43 GMT"
Content-Transfer-Encoding: base64

So it looks like 'application/octet-stream' will do the trick.

天气好吗我好吗 2024-09-06 13:56:28

您可能走在正确的道路上。我首先会询问那些遇到问题的人他们正在使用什么客户端和版本,让他们向您转发他们收到的消息。如果您发现可以从您的客户端正确打开这些消息,请提供可接受的客户端列表,他们可以将其转发给它们作为临时解决方案。

之后,就是深入研究文档,并弄清楚如何使其发挥作用。

祝你好运。

编辑

查明他们是否打开电子邮件纯文本或 html,以及他们的公司是否有任何关于可以配置到其客户端的附件的政策,这可能也是一个好主意。

You are probably on the right track. I would start by asking those who have the issue exactly what client and version they are using, have them forward you the message that they received. And if you find that those messages can be opened correctly from your client, offer a list of acceptable clients they can forward to as a temporary work around.

After that, it's all digging into docs, and figuring out how to make it work.

Good luck.

EDIT

It would probably also be a good idea to find out if they are opening their email plain text, or html, and if their company has any policies about attachments that may be configured into their clients.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文