1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
MailMessage Email = new MailMessage();
MailAddress MailFrom = new MailAddress(strFrom, strFrom);
Email.From = strMailFrom;
Email.To.Add(strTo);
Email.Subject = strSubject; // string contenant le sujet
Email.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-2");
Email.Body = strMessageBody; // string contenant les balises html
SmtpClient SmtpMail = new SmtpClient("tonserveursmtp");
SmtpMail.Credentials = new NetworkCredential("user", "password");
try
{
SmtpMail.Send(Email);
return true;
}
catch (Exception ex)
{
//strError = ex.Message + " : " + ex.Source + " : " + ex.InnerException.ToString();
return false;
}
|
Partager