2009-11-16 10 views
0

chaîne de = "[email protected]"; chaîne à = "xyz @ gmail.com, xyz @ yahoo.co.in"; string password = "abcxyz";Lien Web dans un courrier ne rend pas en tant que lien dans yahoo

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); 

Ce code envoie le courrier avec succès. Quand je regarde mon gmail, le lien "stackoverflow" se traduit par un lien et j'ai pu naviguer vers la page correspondante, mais dans yahoo je ne trouve aucun lien à la place juste le texte "stackoverflow" apparaît.

Répondre

3

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

Vous avez oublié le http://

+3

Je ne pense pas que ce soit le protocole manquant autant que la valeur d'attribut sans guillemets. –

+0

Je viens d'essayer un mail à Yahoo avec 'text', fonctionne pour moi. : P –

+0

Posté ma réponse! –

1

Peut-être Yahoo! Mail est moins indulgent sur les non cotées valeurs d'attribut HTML, essayez ceci:

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

J'ai essayé 'text', semble assez pardonnant dans le courrier de yahoo. –

0

Essayez

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

Essayez spécifiant un HTML valide:

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

Lors de l'envoi en vrac de contenu html comme corps , http importe. C'est le code dans mon fichier de configuration qui m'a dérangé. Quand j'ai ajouté http, cela fonctionne bien, sans http, yahoo échoue.

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