using System; using System.Configuration; using CPE.App.Web.Models; using System.Net.Mail; using CPE.App.Api.Models; using Newtonsoft.Json; namespace CPE.App.Api.Helpers { public class SendEmailHelper { public static bool SendCertificateEmail(PurchasedCourse course) { var courseEmail = course.Email; var emailTest = ConfigurationManager.AppSettings["EmailTest"]; if (!string.IsNullOrWhiteSpace(emailTest)) { courseEmail = emailTest; } //elucidat cert email var cDate = course.CertificateDate.Value.ToString("yyyyMMdd"); MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["EmailSender"], courseEmail); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "localhost"; mail.Subject = ConfigurationManager.AppSettings["EmailSubject"]; string mailBodyText = CPE.Utilities.Email.RenderEmail(course.ContentUrl, course.CertificateDate, course.Ticket); mail.Body = mailBodyText; mail.IsBodyHtml = true; client.Send(mail); return true; } public static bool SendBadReleaseEmail(ReleaseModel release) { MailMessage mail = new MailMessage("support@intesolv.com", ConfigurationManager.AppSettings["EmailReceiver"]); //TODO at DEPLOY: needs to be "sswebcast@cpeincmail.com" or better yet, move to config SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "localhost"; mail.Subject = "A new release wasn't properly updated."; mail.Body = "A new release was processed improperly. Please verify the release description field is correct and create a new release." + Environment.NewLine + "Release code: " + release.ReleaseCode; client.Send(mail); return true; } public static bool SendProjectConfigFailEmail(string projectCode) { //not using. ignoring project_created webhooks MailMessage mail = new MailMessage("support@intesolv.com", ConfigurationManager.AppSettings["EmailReceiver"]); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "localhost"; mail.Subject = "A new project was not configured properly."; mail.Body = "A new project was created but the configuration of the project for tincan failed. " + Environment.NewLine + "Project Code: " + projectCode; client.Send(mail); return true; } public static bool SendCertificateGenerationFailedEmail(TinCanStatementModel statement) { MailMessage mail = new MailMessage("support@intesolv.com", ConfigurationManager.AppSettings["EmailReceiver"]); //TODO at DEPLOY change to "sswebcast@cpeincmail.com" SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Host = "localhost"; mail.Subject = "Certificate Generation Failure"; mail.Body = "A user just passed an on-demand course and something went wrong processing their certificate. " + Environment.NewLine + "Please find the necessary information below for their Certificate of Completion. We recommend that you call InteSolv Support to update the Certificate Record. " + "Certificate information:" + Environment.NewLine + JsonConvert.SerializeObject(statement, Formatting.Indented); client.Send(mail); return true; } } }