views:

91

answers:

5

Hello All,

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.

+3  A: 

<a href="http://www.stackoverflow.com"&gt;stackoverflow&lt;/a&gt;

You forgot the http://

o.k.w
I don't think it is the missing protocol so much as the unquoted attribute value.
Andrew Hare
I just tried one mail to yahoo with `<a href=http://www.website>text</a>`, works for me. :P
o.k.w
Posted my answer!
Sri Kumar
+1 You appear to be correct! :)
Andrew Hare
I was coding some emailing stuff when I saw this post, took me less than a minute to verify with yahoo mail :)
o.k.w
+1  A: 

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\"&gt;stackoverflow&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;";
Andrew Hare
I've tried `<a href=http://www.website.com>text</a>`, seems pretty forgiving in yahoo mail.
o.k.w
A: 

Try

<a href="http://www.stackoverflow.com/"&gt; stackoverflow</a>
claws
A: 

Try specifying a valid html:

mail.Body = "<html><body><h1>My Message</h1><br><a href=\"http://www.stackoverflow.com\"&gt;stackoverflow&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;";
Darin Dimitrov
A: 

Hi,

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>
Sri Kumar