Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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