/// <summary> /// Secondary Send Email method, used to send the final e-mail at tournament's conclusion (includes BCC list). /// </summary> 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 ); GlobalConfig.Connection.InsertSMSLogMessage(Convert.ToDecimal(message.Price), message.PriceUnit, message.Status.ToString(), textMessage.Length, to, fromPhoneNumber); }
public static void SendEmail(string toAddress, string subject, string body) { //Get sendderEmail and senderDisplayName from App.config file MailAddress fromMailAddress = new MailAddress(GlobalConfig.AppKeyLookUp("senderEmail"), GlobalConfig.AppKeyLookUp("senderDisplayName")); MailMessage mail = new MailMessage(); mail.To.Add(toAddress); mail.From = fromMailAddress; mail.Subject = subject; mail.Body = body; mail.IsBodyHtml = true; //Need to enable "Less secure app access" in setting "https://www.google.com/settings/security/lesssecureapps" of server google account //Setup mailSettings in App.config SmtpClient client = new SmtpClient(); client.Send(mail); }
private static void AlertPersonToNewRound(PersonModel p, string teamName, MatchupEntryModel competitor) { if (p.EmailAddress.Length > 0 && GlobalConfig.AppKeyLookUp("communicationPreference") == "Email") { if (IsValidEmail(p.EmailAddress)) { 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>"); // Similar to appending a new line = sb.AppendLine 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; EmailLogic.SendEmail(to, subject, body.ToString()); } } if (p.CellphoneNumber.Length > 0 && GlobalConfig.AppKeyLookUp("communicationPreference") == "SMS") { SMSLogic.SendSMSMessage(p.CellphoneNumber, $"You have a new matchup with {competitor.TeamCompeting.TeamName}"); } }