3 Date Created: 08/24/2016
4 ---------------------------------------------------
8 using System.Configuration;
10 using CPE.App.Notify.Extensions;
11 using CPE.App.Notify.Models.Enums;
13 namespace CPE.App.Notify.Helpers {
14 public class EmailCertificateHelper {
16 /// Email the certificate results to the participant
18 /// <param name="to">Email recipient</param>
19 /// <param name="scoId">Primary key of the meeting room</param>
20 /// <param name="purchaseDate">The date the meeting access was purchased</param>
21 /// <param name="purchaseTicket">The ticket recieved when the meeting room was purchased</param>
22 /// <returns></returns>
23 public static EmailCertificateResults SendWebcastCert(string to, int scoId, DateTime purchaseDate, string purchaseTicket) {
24 var subject = ConfigurationManager.AppSettings["WebcastCertEmailSubject"].Log(message: "Subject");
25 var certUrl = EmailRenderHelper.RenderCertificateLink(scoId, purchaseDate, purchaseTicket)
26 .Log(message: "RenderCertificateLink");
27 var body = EmailRenderHelper.RenderWebcastEmail(certUrl)
28 .Log(message: "Body");
29 return sendEmail(to, subject, body)
34 /// Send a failure notice to the participant
36 /// <param name="to">Email recipient</param>
37 /// <returns></returns>
38 public static EmailCertificateResults SendFailNotice(string to) {
39 var subject = ConfigurationManager.AppSettings["WebcastFailEmailSubject"].Log(message: "Subject");
40 var body = EmailRenderHelper.RenderFailEmail()
41 .Log(message: "Body");
42 return sendEmail(to, subject, body)
49 /// <param name="to">Recipient</param>
50 /// <param name="subject">Subject</param>
51 /// <param name="body">Body</param>
52 /// <returns></returns>
53 private static EmailCertificateResults sendEmail(string to, string subject, string body) {
55 var mail = new MailMessage(ConfigurationManager.AppSettings["WebcastEmailSender"], to) {
60 var client = new SmtpClient {
62 DeliveryMethod = SmtpDeliveryMethod.Network,
63 UseDefaultCredentials = false,
64 Host = ConfigurationManager.AppSettings["EmailServer"]
67 } catch (Exception exception) {
68 exception.Log(LoggingLevels.Fatal);
69 return EmailCertificateResults.Fail;
72 return EmailCertificateResults.Success;