Last active
April 19, 2016 18:42
-
-
Save syron/3f29b7f31ee087f7b1b71715a119ac16 to your computer and use it in GitHub Desktop.
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
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