Bon voila mon code, il ne marche pas toujours il affiche "Failure Sent Mail" un peu d'aide svp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Windows.Forms;
using System.Net.Mail;
namespace TestMailSendSMTP
{
class Program
{
static void Main(string[] args)
{
MailMessage mm = new MailMessage("source@gmail.com", "dest@gmail.com");
// content
mm.Subject = "testing message";
mm.Body = "hello... from .net c# mailmessage";
mm.CC.Add("oucha21@gmail.com");
// Sending message
SmtpClient sc = new SmtpClient("smtp.gmail.com", 587);
// our account credentials
sc.Credentials = new NetworkCredential("source@gmail.com", "pass", "");
sc.EnableSsl = true;
// Catching result
try
{
sc.Send(mm);
MessageBox.Show("Message sent");
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}
}
}