Skip to content

Instantly share code, notes, and snippets.

@belsrc
Last active October 13, 2015 04:47
Show Gist options
  • Save belsrc/4141280 to your computer and use it in GitHub Desktop.
Save belsrc/4141280 to your computer and use it in GitHub Desktop.
Send SMTP Mail - C#
private void SendEmail(string from, IEnumerable<string> to, string subj, string body, bool isHtml = false, SmtpClient client) {
MailMessage message = new MailMessage();
message.From = new MailAddress( from );
foreach( string copy in cc ) {
message.To.Add( new MailAddress( copy ));
}
message.Subject = subj;
message.Body = body;
message.IsBodyHtml = isHtml;
message.Priority = MailPriority.High;
try {
client.Send( message );
}
catch( Exception ex ) {
//TODO: Handle exceptions
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment