MailMessage编码&前景不正确

时间:2015-05-10 05:24:37

标签: vb.net smtp mailmessage

我正在尝试以HTML格式发送此消息

您好Ryan Fishman,

请点击https://www.asportsmanager.com/#ConfirmRegistration?username=batmanbond3dd&registrationtoken=3Dc95e54e4-b099-4338-ad34-fd418e9b4ca1">here to注册asportsmanager.com。

使用此vb.net代码

        Dim mm As New MailMessage


        mm.From = New MailAddress(ConfigObject.SendEmailSender)
        mm.To.Add(New MailAddress(ToAddress))
        mm.Subject = Subject
        mm.IsBodyHtml = IsBodyHTML
        mm.Body = Nothing

        Dim ABody As AlternateView = Net.Mail.AlternateView.CreateAlternateViewFromString(Body)
        ABody.TransferEncoding = Mime.TransferEncoding.SevenBit
        ABody.ContentType = New Mime.ContentType("text/html; charset=""utf-8""")
        mm.AlternateViews.Add(ABody)

        Dim smtpclient As New SmtpClient(ConfigObject.SendEmailServer)
        smtpclient.UseDefaultCredentials = False
        smtpclient.Credentials = New System.Net.NetworkCredential(ConfigObject.SendEmailUsername, ConfigObject.SendEmailPassword)
        smtpclient.Send(mm)

当我将此电子邮件发送到Gmail帐户时,邮件显示正常。出于某种原因,当它被发送到hotmail(outlook)电子邮件时,链接显示为

https://www.asportsmanager.com/#ConfirmRegistration?username=batmanbond3dd%c2%aeistrationtoken=313a97f2-5a18-4dd8-b8cb-d6ab617f897d

注意%c2%ae应为& reg。

请帮忙。

1 个答案:

答案 0 :(得分:0)

似乎由于某种原因,前景与%c2%ae一起逃脱& reg。对我来说这是一个很好的解决方法,就是用& token来改变和注册。