我们有一个网站,我们会在新客户注册时向我们的客户发送自动生成的邮件。我们的邮件有一个看起来像
的激活链接但是当我们的德国客户收到邮件时,他会收到以下激活链接,您会注意到&字符更改为®
http://www.bba-reman.com/catalogue/ConfirmRegistration.aspx?email=meyer@reman.de®id= 907a5253-106c-4fb3-9882-83e634e651b2
任何人都可以告诉我为什么&角色变为®?
如何解决这类问题?
答案 0 :(得分:1)
尝试使用CreateAlternateViewFromString
属性,这是示例代码
MailMessage emailmsg = new MailMessage("from@address.co.za", "to@address.co.za")
emailmsg.Subject = "Subject";
emailmsg.IsBodyHtml = false;
emailmsg.ReplyToList.Add("from@address.co.za");
emailmsg.BodyEncoding = System.Text.Encoding.UTF8;
emailmsg.HeadersEncoding = System.Text.Encoding.UTF8;
emailmsg.SubjectEncoding = System.Text.Encoding.UTF8;
emailmsg.Body = null;
var plainView = AlternateView.CreateAlternateViewFromString(EmailBody, emailmsg.BodyEncoding, "text/plain");
plainView.TransferEncoding = TransferEncoding.SevenBit;
emailmsg.AlternateViews.Add(plainView);
SmtpClient sSmtp = new SmtpClient();
sSmtp.Send(emailmsg);