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
| public static string sendMail(string to, string cc, string bcc, string subj, string msg)
{
SmtpClient smtp = new SmtpClient();
MailMessage message = new MailMessage();
try
{
message.To.Add(new MailAddress(to));
message.Subject = subj;
message.Body = msg;
smtp.Host = "smtpserver"; // hostname smtpserver
smtp.Port = 2525; // smtp server port
message.From = new MailAddress("user@serveur.com");
smtp.Send(message);
}
catch (SmtpException E)
{
return "Mail send failed with message: " + E.Message;
}
return "Mail was send";
} |