2 using System.Configuration;
3 using CPE.App.Web.Models;
5 using CPE.App.Api.Models;
8 namespace CPE.App.Api.Helpers
10 public class SendEmailHelper
12 public static bool SendCertificateEmail(PurchasedCourse course)
14 var courseEmail = course.Email;
15 var emailTest = ConfigurationManager.AppSettings["EmailTest"];
16 if (!string.IsNullOrWhiteSpace(emailTest))
18 courseEmail = emailTest;
22 var cDate = course.CertificateDate.Value.ToString("yyyyMMdd");
23 MailMessage mail = new MailMessage(ConfigurationManager.AppSettings["EmailSender"], courseEmail);
24 SmtpClient client = new SmtpClient();
26 client.DeliveryMethod = SmtpDeliveryMethod.Network;
27 client.UseDefaultCredentials = false;
28 client.Host = "localhost";
29 mail.Subject = ConfigurationManager.AppSettings["EmailSubject"];
30 string mailBodyText = CPE.Utilities.Email.RenderEmail(course.ContentUrl, course.CertificateDate, course.Ticket);
31 mail.Body = mailBodyText;
32 mail.IsBodyHtml = true;
37 public static bool SendBadReleaseEmail(ReleaseModel release)
39 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
40 SmtpClient client = new SmtpClient();
42 client.DeliveryMethod = SmtpDeliveryMethod.Network;
43 client.UseDefaultCredentials = false;
44 client.Host = "localhost";
45 mail.Subject = "A new release wasn't properly updated.";
46 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;
51 public static bool SendProjectConfigFailEmail(string projectCode)
53 //not using. ignoring project_created webhooks
54 MailMessage mail = new MailMessage("support@intesolv.com", ConfigurationManager.AppSettings["EmailReceiver"]);
55 SmtpClient client = new SmtpClient();
57 client.DeliveryMethod = SmtpDeliveryMethod.Network;
58 client.UseDefaultCredentials = false;
59 client.Host = "localhost";
60 mail.Subject = "A new project was not configured properly.";
61 mail.Body = "A new project was created but the configuration of the project for tincan failed. " + Environment.NewLine + "Project Code: " + projectCode;
65 public static bool SendCertificateGenerationFailedEmail(TinCanStatementModel statement)
67 MailMessage mail = new MailMessage("support@intesolv.com", ConfigurationManager.AppSettings["EmailReceiver"]); //TODO at DEPLOY change to "sswebcast@cpeincmail.com"
68 SmtpClient client = new SmtpClient();
70 client.DeliveryMethod = SmtpDeliveryMethod.Network;
71 client.UseDefaultCredentials = false;
72 client.Host = "localhost";
73 mail.Subject = "Certificate Generation Failure";
74 mail.Body = "A user just passed an on-demand course and something went wrong processing their certificate. " + Environment.NewLine
75 + "Please find the necessary information below for their Certificate of Completion. We recommend that you call InteSolv Support to update the Certificate Record. "
76 + "Certificate information:" + Environment.NewLine
77 + JsonConvert.SerializeObject(statement, Formatting.Indented);