当使用德语变音符和名称逗号时,错误的电子邮件接收器显示 [英] Erroneous email receiver display when using German umlauts and a comma in name

查看:247
本文介绍了当使用德语变音符和名称逗号时,错误的电子邮件接收器显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用的建议,我发送了Microsoft网络监视器,同时发送电子邮件消息。



对我来说,似乎 MailMessage 类(或 SmtpClient class?)已经做错了:



解决方案

所以,经过一番挖掘,我遇到了Microsoft支持文章2576045 :修复:电子邮件客户端不支持由 .NET F中的MailMessage 类如果名称包含一个非ASCII字符,则作业4。



看起来,当写出包含Unicode字符的地址时, MailMessage 类不正确编码某些东西。我肯定不能告诉你它是基于知识库文章的信息,但无论如何,这足以使下游的读者窒息在标题。


Using the MailMessage class in .NET 4, I found an issue today that I'm unable to resolve so far. Please see the following code:

using (var message = new MailMessage())
{
    message.From = new MailAddress(@"uwe.keim@gmail.com", "Uwe Keim");
    message.Bcc.Add(new MailAddress(@"uk@zeta-software.de", "Uwe Keim"));

    // This fails (see screenshot).
    /*1*/ message.To.Add(new MailAddress(@"uk2@zeta-sw.net", "Müller, Fred"));

    // This succeeds.
    /*2*/ message.To.Add(new MailAddress(@"uk2@zeta-sw.net", "Fred Müller"));

    // This also succeeds.
    /*3*/ message.To.Add(new MailAddress(@"uk2@zeta-sw.net", "Muller, Fred"));

    message.Subject = "Test";
    message.Body = "Some text body.";

    new SmtpClient().Send(message);
}

This is a simple snippet so send an SMTP message. Mutually trying the lines /*1*/, /*2*/ and /*3*/, the behavior differs:

Whenever a receiver ("To") name contains a German umlaut (i.e. "Ä", "Ö" or "Ü") and a comma (i.e. ","), the receiver sees damaged text in the email message he receives:

As you can see in the above screenshot (taken from Outlook 2010), there is a cryptic "=?utf-8?Q?M=C3=BCller" in the "To:" line.

Leaving out the comma or removing the German umlaut fixes this. I've tried both Exchange 2003 and hmailserver to get the same result.

My question is:

Is anyone aware of this behaviour and has a solution to it?

Update 1:

As suggested by user Adam Maras, I fired up Microsoft Network Monitor while sending the email message.

To me, it seems that the MailMessage class (or the SmtpClient class?) is already doing it wrong:

解决方案

So, after some digging, I came across Microsoft Support article 2576045: FIX: Email client does not support a name in a delivery address field that is encoded by the MailMessage class in the .NET Framework 4 if the name contains a non-ASCII character.

It appears that, when writing out an address that contains Unicode characters, the MailMessage class does not correctly encode something. I certainly can't tell you what it is based on the KB article's information, but whatever it is, it's enough to make downstream readers choke on the headers.

这篇关于当使用德语变音符和名称逗号时,错误的电子邮件接收器显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆