1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public class Mail
{
private System.Net.Mail.MailMessage _mail = new System.Net.Mail.MailMessage();
public Mail(string fromName, string fromMail, string toName, string toMail, string subject, string body, bool isHtml)
{
this._mail.Subject = subject;
this._mail.Body = body;
this._mail.From = new System.Net.Mail.MailAddress(fromMail, fromName);
this._mail.To.Add(new System.Net.Mail.MailAddress(toMail, toName));
this._mail.IsBodyHtml = isHtml;
this._mail.BodyEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
this._mail.SubjectEncoding = System.Text.Encoding.GetEncoding("iso-8859-1");
}
public bool Send()
{
try
{
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("localhost"); // Mettre le serveur smtp ici
smtp.Send(this._mail);
return true;
}
catch (Exception) { return false; }
}
} |