【问题标题】:ASPX Hyperlink appearing as plain text in emailASPX 超链接在电子邮件中显示为纯文本
【发布时间】:2017-08-09 04:34:51
【问题描述】:

我只想发送一封带有超链接的电子邮件,但它一直显示为纯文本:

按钮点击:

    protected void Button1_Click(object sender, EventArgs e)
    {
            currURL = Request.Url.Authority + HttpContext.Current.Request.ApplicationPath;

            string emailSubject = "Hello World";
            string emailBody = "Please click <a href='" + currURL "'>HERE</a>" Debug: " + currURL;

            myClass.SendEmail(tb_EmailTo.Text, emailSubject, emailBody);
    }

发送电子邮件的代码:

    public static void SendEmail(string sendTo, string subject, string body, bool isBodyHTML = true)
    {
        SmtpClient Smtp_Server = new SmtpClient();
        MailMessage e_mail = new MailMessage();
        Smtp_Server.UseDefaultCredentials = false;
        Smtp_Server.Credentials = new System.Net.NetworkCredential(---, ---);
        Smtp_Server.Port = thePort;
        //Smtp_Server.EnableSsl = True
        Smtp_Server.Host = theHost;

        e_mail = new MailMessage();
        e_mail.From = new MailAddress(theSendFromAddress);

        e_mail.To.Add(sendTo);

        string currPathAndQuery = HttpContext.Current.Request.Url.PathAndQuery;
        string currURL = HttpContext.Current.Request.Url.AbsoluteUri.Replace(currPathAndQuery, "/");

        e_mail.Subject = subject;
        e_mail.IsBodyHtml = true;
        e_mail.Body = body;
        Smtp_Server.Send(e_mail);
    }

电子邮件的正文是:

请点击这里调试:localhost:12345/

这里应该是一个指向 localhost:12345/ 的超链接,但它一直显示为纯文本。

【问题讨论】:

    标签: c# asp.net email


    【解决方案1】:

    没关系,原来是链接:currURL 出现问题,添加 http:// 就可以了

    【讨论】:

      猜你喜欢
      • 2015-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-09
      • 2011-07-15
      • 2018-06-13
      • 2021-05-20
      • 1970-01-01
      相关资源
      最近更新 更多