Skip to content

Instantly share code, notes, and snippets.

@syron
Last active April 19, 2016 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syron/3f29b7f31ee087f7b1b71715a119ac16 to your computer and use it in GitHub Desktop.
Save syron/3f29b7f31ee087f7b1b71715a119ac16 to your computer and use it in GitHub Desktop.
bool isImportantEmail = false;
string fromEmail = "robert.mayer@afconsult.com";
string toEmail = "robert.mayer@afconsult.com";
int smtpPort = 587;
bool smtpEnableSsl = true;
string smtpHost = "";
string smtpUser = "";
string smtpPass = "";
string subject = "";
string message = "";
MailMessage mail = new MailMessage(fromEmail, toEmail);
SmtpClient client = new SmtpClient();
client.Port = smtpPort;
client.EnableSsl = smtpEnableSsl;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = smtpHost;
client.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPass);
mail.Subject = message;
if (isImportantEmail) {
mail.Priority = MailPriority.High;
}
mail.Body = message;
try {
client.Send(mail);
}
catch (Exception ex) {
System.Diagnostics.Trace.WriteLine(ex.ToString());
throw ex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment