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 27 28 29
|
public class mail
{
private MailMessage _mail = new MailMessage();
public void 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 MailAddress(fromMail, fromName);
string[] dest=toMail.Split(',');
for (int x = 0; x < dest.Length; x++)
{
this._mail.To.Add(new MailAddress(dest[x].ToString(), 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
{
SmtpClient smtp = new SmtpClient("smtp.cabinetrichard.fr");smtp.Send(this._mail);
return true;
}
catch (Exception) { return false; }
}
} |
Partager