public bool SendEmail(string toAddress, string subject, string body, bool ccRegistration) { if (Server == null || FromEmailAddress == null) { return(false); } MailMessage message = new MailMessage(); try { message.To.Add(SmtpDirect.ClassicList(toAddress)); message.From = new MailAddress(FromEmailAddress); if (ccRegistration && CCEmailAddress.Length != 0) { message.CC.Add(SmtpDirect.ClassicList(CCEmailAddress)); } } catch (Exception ex) { // you should be calling CheckEmailAddy() first to avoid this error LogHelper.LogException(ex); return(false); } message.Subject = subject; message.Body = body; return(Send(message)); }
public bool SendEmail(string toAddress, string subject, string body, bool ccRegistration) { if (Server == null || FromEmailAddress == null) { return(false); } MailMessage message = new MailMessage(); message.To.Add(SmtpDirect.ClassicList(toAddress)); message.From = new MailAddress(FromEmailAddress); if (ccRegistration && CCEmailAddress.Length != 0) { message.CC.Add(SmtpDirect.ClassicList(CCEmailAddress)); } message.Subject = subject; message.Body = body; return(Send(message)); }
// check the form of this address or list. // Under the message.to.Add is a call to System.Net.Mime.MailBnfHelper() which // which validates the form public static bool CheckEmailAddy(string address, bool AllowList) { try { if (AllowList == false) { if (address.IndexOf(',') >= 0 || address.IndexOf(';') >= 0) { return(false); } } MailMessage message = new MailMessage(); message.To.Add(SmtpDirect.ClassicList(address)); } catch { // bad format return(false); } // good form return(true); }
private static void SendEmail(string body, bool testcenter) { Console.Write("Sending email..."); try { MailMessage message = new MailMessage(); if(testcenter) message.Subject = "Automated RunUO Rebuild/Merge Report Test Center"; else message.Subject = "Automated RunUO Rebuild/Merge Report Production"; message.From = new MailAddress(SmtpDirect.FromEmailAddress); message.To.Add(SmtpDirect.ClassicList(Emails)); message.Body = "Automated RunUO Rebuild/Merge Report" + body; bool result = new SmtpDirect().SendEmail(message); Console.WriteLine("done: {0}", result.ToString()); } catch { Console.WriteLine("failed"); } }
private static void SendEmail( string filePath ) { Console.Write( "Crash: Sending email..." ); try { MailMessage message = new MailMessage(); message.Subject = "Automated RunUO Crash Report"; if( Server.Misc.TestCenter.Enabled ) { message.Subject += " (Test Center)"; } message.From = new MailAddress(SmtpDirect.FromEmailAddress); message.To.Add(SmtpDirect.ClassicList(Emails)); message.Body = "Automated RunUO Crash Report. See attachment for details."; message.Attachments.Add(SmtpDirect.MailAttachment(filePath)); bool result = new SmtpDirect().SendEmail( message ); Console.WriteLine( "done: {0}", result.ToString() ); } catch { Console.WriteLine( "failed" ); } }
public static object StandardEmail(object parms) { try { ParamPack px = parms as ParamPack; // hmm.. badness if (px == null || px.m_toAddress == null) { string message = String.Format("Error: in Accounting.Emailer. paramater pack."); throw new ApplicationException(message); } // Adam: bacause we may send this to both the recipient and the email archive server // we allow distribution lists if (SmtpDirect.CheckEmailAddy(px.m_toAddress, true) == false) { string message = String.Format("Email: Bad address detected '{0}'.", px.m_toAddress); throw new ApplicationException(message); } SmtpDirect mail = new SmtpDirect(); mail.SendEmail(px.m_toAddress, px.m_subject, px.m_body, px.m_ccRegistration); return true; } catch (Exception e) { LogHelper.LogException(e); Console.WriteLine("Exception: " + e.Message); Console.WriteLine(e.StackTrace); } return false; }