Last active
October 13, 2015 04:47
-
-
Save belsrc/4141280 to your computer and use it in GitHub Desktop.
Send SMTP Mail - C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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