邮件中的 Web 链接未在 yahoo 中呈现为链接

发布于 2024-08-11 09:57:15 字数 1187 浏览 3 评论 0原文

string from = "[电子邮件受保护]"; string to = "[电子邮件受保护],[电子邮件受保护]"; 字符串密码=“abcxyz”;

MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from, "Check Email", System.Text.Encoding.UTF8);
mail.Subject = "This is a test mail";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "<html><body><h1>My Message</h1><br><a href=www.stackoverflow.com>stackoverflow</a></body></html>";
mail.IsBodyHtml = true;

SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(from,password);
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true; 
client.Send(mail);

此代码已成功发送邮件。当我查看我的 gmail 时,“stackoverflow”链接呈现为链接,我能够导航到相应的页面,但在 yahoo 中我找不到任何链接,而只出现文本“stackoverflow”。

string from = "[email protected]";
string to = "[email protected],[email protected]";
string password="abcxyz";

MailMessage mail = new System.Net.Mail.MailMessage();
mail.To.Add(to);
mail.From = new MailAddress(from, "Check Email", System.Text.Encoding.UTF8);
mail.Subject = "This is a test mail";
mail.SubjectEncoding = System.Text.Encoding.UTF8;
mail.Body = "<html><body><h1>My Message</h1><br><a href=www.stackoverflow.com>stackoverflow</a></body></html>";
mail.IsBodyHtml = true;

SmtpClient client = new SmtpClient();
client.Credentials = new System.Net.NetworkCredential(from,password);
client.Port = 587;
client.Host = "smtp.gmail.com";
client.EnableSsl = true; 
client.Send(mail);

This code successfully sents the mail. When i look at my gmail, the "stackoverflow" link renders as link and i was able to navigate to the respective page, but in yahoo i don't find any link instead just the text "stackoverflow" appears.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

缺⑴份安定 2024-08-18 09:57:15

stackoverflow

您忘记了 http://

<a href="http://www.stackoverflow.com">stackoverflow</a>

You forgot the http://

情痴 2024-08-18 09:57:15

也许雅虎! Mail 对于不带引号的 HTML 属性值不太宽容,请尝试以下操作:

mail.Body 
    = "<html><body><h1>My Message</h1><br><a href=\"http://www.stackoverflow.com\">stackoverflow</a></body></html>";

Perhaps Yahoo! Mail is less forgiving about unquoted HTML attribute values, try this instead:

mail.Body 
    = "<html><body><h1>My Message</h1><br><a href=\"http://www.stackoverflow.com\">stackoverflow</a></body></html>";
风月客 2024-08-18 09:57:15

尝试

<a href="http://www.stackoverflow.com/"> stackoverflow</a>

Try

<a href="http://www.stackoverflow.com/"> stackoverflow</a>
随波逐流 2024-08-18 09:57:15

尝试指定一个有效的 html:

mail.Body = "<html><body><h1>My Message</h1><br><a href=\"http://www.stackoverflow.com\">stackoverflow</a></body></html>";

Try specifying a valid html:

mail.Body = "<html><body><h1>My Message</h1><br><a href=\"http://www.stackoverflow.com\">stackoverflow</a></body></html>";
关于从前 2024-08-18 09:57:15

当发送大量 html 内容作为正文时,http 确实很重要。这是我的配置文件中的代码让我感到困扰。当我添加http时,它工作正常,没有http,雅虎失败。

<tr>
  <td colspan="2"  onClick="#stackoverflow#" style="cursor:hand;">
    <center>
     <b>
       <a href='http://www.stackoverflow.com' style="color:#1C0693;text-decoration:none;">stackoverflow</a>
     </b>
    </center>
 </td>
</tr>

When sending bulk of html content as body, http do matter. This is the code in my config file troubled me. When i added http, it works fine, without http, yahoo fails.

<tr>
  <td colspan="2"  onClick="#stackoverflow#" style="cursor:hand;">
    <center>
     <b>
       <a href='http://www.stackoverflow.com' style="color:#1C0693;text-decoration:none;">stackoverflow</a>
     </b>
    </center>
 </td>
</tr>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文