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