MailMessage,发件人的显示名称是" ???????"

时间:2014-06-16 21:13:22

标签: c# smtpclient mailmessage

问题:我得到了“???????”而不是发送者的显示名称(显示名称是utf8文本,也尝试使用System.Web.Mail.MailMessage但得到相同的结果):

var fromAddress = new MailAddress("from@mail.com", "Some UTF8 text");
    var toAddress = new MailAddress(toAddress);

    var client = new SmtpClient
    {
        Host = "smpt.server",
        Port = 465,
        EnableSsl = true,
        DeliveryMethod = SmtpDeliveryMethod.Network,
        UseDefaultCredentials = false,
        Credentials = new NetworkCredential(fromAddress.Address, "password"),
        Timeout = 5000
    };
    var message = new MailMessage(fromAddress, toAddress)
    {
        Subject = title,
        Body = messageStr,
        IsBodyHtml = true
    };

1 个答案:

答案 0 :(得分:3)

您是否尝试过更改构造函数?

 var fromAddress = new MailAddress("from@mail.com", "Some UTF8 text", System.Text.Encoding.UTF8);

MailAddress Constructor (String, String, Encoding)