SMTPClient.Send 无法解析特殊字符

发布于 2025-01-05 04:43:12 字数 132 浏览 1 评论 0原文

我们正在使用 SmtpClient.Send 发送邮件。但不幸的是,具有一些特殊字符(如“æ”、“ø”和“å”(以及许多此类字符)的邮件正文无法正确发送,并且在收到时这些字符被损坏。

任何帮助将不胜感激。

问候, 稻田

We are using SmtpClient.Send to send mail. But unfortunately the mail body which is having some special character like "æ", "ø" and "å" (and many such) are not getting send properly and on reciept those character is getting corrupted.

Any help will be appreciated.

Regards,
Paddy

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

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

发布评论

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

评论(1

衣神在巴黎 2025-01-12 04:43:12

SmtpClient.Send 使用的默认编码是 us-ascii。您需要使用接收 MailMessage 的 覆盖 并设置邮件的 < href="http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.bodyencoding.aspx" rel="nofollow">BodyEncoding 属性包含您需要的特殊字符的编码。您可以对 SubjectEncoding 属性,对主题中的特殊字符进行编码。

您可以使用 Unicode 编码,但文档警告您消息的 TransferEncoding 将转换为 Base64。几乎所有电子邮件客户端都可以处理此问题,因此我认为这不会成为问题。

The default encoding used by SmtpClient.Send is us-ascii. You need to use the override that receives a MailMessage and set the message's BodyEncoding property to an encoding that contains the special characters you need. You can do the same for the SubjectEncoding property, to encode special characters in the Subject.

You can use a Unicode encoding but the documentation warns that your message's TransferEncoding will be converted to Base64. Almost all email clients can handle this, so I don't thing this will be an issue.

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