Envoi de mail : Erreur inexplicable
Bonsoir,
Cette fois-ci je me bat avec une erreur dans l'envoi de mail. D'après des recherche je suis arrivé à ce code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
MailMessage mail = new MailMessage();
mail.To.Add("destinataire@yahoo.fr");
mail.From = new MailAddress("moi@yahoo.fr");
mail.Subject = "Test Email";
string Body = "<b>Bonjour!!</b></br>Ceci est un test d'envoi de mail depuis le SMTP de Yahoo.fr ";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.mail.yahoo.fr";
smtp.Port = 465;
smtp.Credentials = new System.Net.NetworkCredential("moi@yahoo.fr", "mdp","");
smtp.EnableSsl = true;
smtp.Send(mail); |
L'erreur que je reçois est :
Citation:
Impossible d'envoyer le message
Pourtant, en le serveur SMTP et le compte mail de yahoo par gmail ça marche ?
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
MailMessage mail = new MailMessage();
mail.To.Add("destinataire@yahoo.fr");
mail.From = new MailAddress("moi@gmail.com");
mail.Subject = "Test Email";
string Body = "<b>Test envoi mail</b>";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.Credentials = new System.Net.NetworkCredential("moi@gmail.com", "mdp");
smtp.EnableSsl = true;
smtp.Send(mail); |
Où est le problème s'il vous plait ?