public static void SendEmail(List <string> to, List <string> bcc, string subject, string body) { MailAddress fromMailAddress = new MailAddress(GlobalConfig.AppKeyLookup("senderEmail"), GlobalConfig.AppKeyLookup("senderDisplayName")); MailMessage mail = new MailMessage(); foreach (string email in to) { mail.To.Add(email); } foreach (string email in bcc) { mail.To.Add(email); } mail.From = fromMailAddress; mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; SmtpClient client = new SmtpClient(); try { client.Send(mail); } catch (System.Net.Mail.SmtpException) { // error will ecore if there is no one to listen to email //recammend using "papercut smpt" to see sent emails } }
public static void SendEmail(List <string> to, List <string> bcc, string subject, string body) { MailAddress fromMailAddress = new MailAddress(GlobalConfig.AppKeyLookup("senderEmail"), GlobalConfig.AppKeyLookup("senderDisplayName")); MailMessage mail = new MailMessage(); foreach (string email in to) { mail.To.Add(email); } foreach (string email in bcc) { mail.Bcc.Add(email); } mail.From = fromMailAddress; mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.Send(mail); }
public static void SendSMSMessage(string to, string textMessage) { string accountSid = GlobalConfig.AppKeyLookup("smsAccountSid"); string authToken = GlobalConfig.AppKeyLookup("smsAuthToken"); string fromPhoneNumber = GlobalConfig.AppKeyLookup("smsFromPhoneNumber"); TwilioClient.Init(accountSid, authToken); var message = MessageResource.Create(to: new PhoneNumber(to), from: new PhoneNumber(fromPhoneNumber), body: textMessage); }
public static void SendEmail(string to, string subject, string body) { MailAddress fromMailAddress = new MailAddress(GlobalConfig.AppKeyLookup("senderEmail"), GlobalConfig.AppKeyLookup("senderDisplayName")); MailMessage mail = new MailMessage(); mail.To.Add(to); mail.From = fromMailAddress; mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.Send(mail); }
public static void SendEmail(List <string> to, List <string> bcc, string subject, string body) { MailAddress fromMailAddress = new MailAddress(GlobalConfig.AppKeyLookup("senderEmail"), GlobalConfig.AppKeyLookup("senderDisplayName")); MailMessage mail = new MailMessage { From = fromMailAddress, Subject = subject, Body = body }; to.ForEach(x => mail.To.Add(x)); bcc.ForEach(x => mail.Bcc.Add(x)); mail.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.Send(mail); }
public static void SendEmail(List <string> to, List <string> bcc, string subject, string body) { string fromAddress = GlobalConfig.AppKeyLookup("senderEmail"); string displayName = GlobalConfig.AppKeyLookup("senderDisplayName"); MailAddress fromMailAddress = new MailAddress(fromAddress, displayName); MailMessage mail = new MailMessage(); to.ForEach(address => { mail.To.Add(address); }); bcc.ForEach(address => { mail.Bcc.Add(address); }); mail.From = fromMailAddress; mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; SmtpClient client = new SmtpClient(); client.Send(mail); }
private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor) { if (p.EmailAddress.Length > 0) { string to = ""; string subject = ""; StringBuilder body = new StringBuilder(); if (competitor != null) { subject = $"You have a new matchup with { competitor.TeamCompeting.TeamName }"; body.AppendLine("<h1>You have a new matchup</h1>"); body.Append("<strong>Competitor: </strong>"); body.Append(competitor.TeamCompeting.TeamName); body.AppendLine(); body.AppendLine(); body.AppendLine("Have a great time!"); body.AppendLine("~Tournament Tracker"); } else { subject = "You have a bye week this round"; body.AppendLine("Enjoy your round off!"); body.AppendLine("~Tournament Tracker"); } to = p.EmailAddress; GlobalConfig.AppKeyLookup("senderEmail"); EmailLogic.SendEmail(to, subject, body.ToString()); } if (p.CellphoneNumber.Length > 0) { SMSLogic.SendSMSMessage(p.CellphoneNumber, $"You have a new matchup with { competitor.TeamCompeting.TeamName }"); } }
public static void SendEmail(string toEmail, string subject, string body) { // Provide FROM address as defined in the App.config file MailAddress fromEmail = new MailAddress(GlobalConfig.AppKeyLookup("senderEmail"), GlobalConfig.AppKeyLookup("senderEmailDisplayName")); // Create a new blank email MailMessage mail = new MailMessage(); // Add details to the blank email mail.To.Add(toEmail); mail.From = fromEmail; mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; // Create email client as defined in App.cofig file SmtpClient client = new SmtpClient(); // Tell client to send email client.Send(mail); }
public static void SendSMSMessage(string to, string textMessage) { string accountSid = GlobalConfig.AppKeyLookup("smsAccountSid"); string authToken = GlobalConfig.AppKeyLookup("smsAuthToken"); string fromPhoneNumber = GlobalConfig.AppKeyLookup("smsFromPhoneNumber"); //Uses twilio nuget package to send SMS messages. //The accountSid and authToken are from the created Twilio account online. TwilioClient.Init(accountSid, authToken); try { var message = MessageResource.Create( to: new PhoneNumber(to), from: new PhoneNumber(fromPhoneNumber), body: textMessage ); } catch { } }