public bool Send(NotificationType notificationType, string subject, string body, string recipients) { var sendEmail = notificationType.GetAttribute <NotificationAttribute>().SendEmail; if (sendEmail) { subject = _emailSubjectStart + subject; subject += WebConfigHelper.IsLocal ? " " + _emailSubjectMarkForLocal : (WebConfigHelper.IsTest ? " " + _emailSubjectMarkForTest : null); var notfAttr = notificationType.GetAttribute <NotificationAttribute>(); if (notfAttr == null) { throw new Exception("Notification Attribute not found!"); } var editionMailTemplate = new EditionMailTemplate { Recipients = recipients, Subject = subject, Body = body, ButtonText = notfAttr.ButtonText, PartialViewName = notfAttr.ViewName }; var mailer = new UserMailer.UserMailer(); mailer.Send(editionMailTemplate, notfAttr.PrivateEmail); return(true); } return(false); }
private EditionMailTemplate GetEmailTemplateForEditionCreation(EditionEntity edition) { var recipients = WebConfigHelper.NewEventNotificationRecipients; var recipientFullName = ""; var notificationAttr = NotificationType.EditionCreated.GetAttribute <NotificationAttribute>(); var buttonUrl = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment); var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty; var emailTemplate = new EditionMailTemplate { Recipients = recipients, RecipientFullName = recipientFullName, ButtonUrl = buttonUrl, UnsubscriptionUrl = unsubscriptionUrl }; return(emailTemplate); }
private EditionMailTemplate GetEmailTemplateForEditionUpdateNotification(EditionEntity edition) { var recipients = _eventDirectorServices.GetRecipientEmails(edition); var recipientFullName = _editionHelper.GetEventDirectorFullName(edition); var notificationAttr = NotificationType.EditionLocationUpdated.GetAttribute <NotificationAttribute>(); var buttonUrl = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment); var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty; var emailTemplate = new EditionMailTemplate { Recipients = recipients, RecipientFullName = recipientFullName, ButtonUrl = buttonUrl, UnsubscriptionUrl = unsubscriptionUrl }; return(emailTemplate); }
public virtual MvcMailMessage Send(EditionMailTemplate mailTemplate, bool isPrivate) { ViewBag.EditionId = mailTemplate.EditionId; ViewBag.EventId = mailTemplate.EventId; ViewBag.AxEventId = mailTemplate.AxEventId; ViewBag.EditionName = mailTemplate.EditionName; ViewBag.EventName = mailTemplate.EventName; ViewBag.Title = mailTemplate.Subject; ViewBag.EventDirectorFullName = mailTemplate.RecipientFullName; ViewBag.CedLogoUrl = WebConfigHelper.CedLogoUrl; ViewBag.WebLogoUrl = mailTemplate.WebLogoUrl; ViewBag.VenueName = mailTemplate.VenueName; ViewBag.DisplayDate = mailTemplate.DisplayDate; ViewBag.Body = mailTemplate.Body; ViewBag.ButtonText = mailTemplate.ButtonText; ViewBag.Url = mailTemplate.ButtonUrl; ViewBag.UnsubscriptionUrl = mailTemplate.UnsubscriptionUrl; ViewBag.GuideUrl = WebConfigHelper.ApplicationAbsolutePath + WebConfigHelper.QuickStartGuideFilePath; var msg = Populate(x => { x.Subject = mailTemplate.Subject; x.ViewName = mailTemplate.PartialViewName; if (!isPrivate) { x.To.Add(mailTemplate.Recipients); } else { x.Bcc.Add(mailTemplate.Recipients); } x.Bcc.Add(WebConfigHelper.AdminEmails); x.ReplyToList.Add(WebConfigHelper.AdminEmails); }); msg.Send(); return(msg); }
internal EmailResult SendNotificationEmailForEditionCreation(EditionEntity edition, EditionTranslationEntity editionTranslation, EditionMailTemplate emailTemplate) { if (!string.IsNullOrWhiteSpace(emailTemplate.Recipients)) { const NotificationType notificationType = NotificationType.EditionCreated; var recipientFullName = emailTemplate.RecipientFullName; var body = "Hello," + "<br/><br/>" + $"This is to inform you that a new event has been created with a name {edition.EditionName}." + @"<br/><br/> Please click the button below to go to event's page."; var buttonUrl = _editionHelper.GetEditionUrl(edition); return(_emailNotificationHelper.Send(edition, editionTranslation, notificationType, recipientFullName, body, emailTemplate.Recipients, buttonUrl, emailTemplate.UnsubscriptionUrl)); } return(new EmailResult { Sent = false, ErrorMessage = "Event doesn't fit the necessary criteria for emailing." }); }
private EmailResult SendNotificationEmailForEditionLocationUpdate(EditionEntity edition, EditionTranslationEntity editionTranslation, EditionMailTemplate emailTemplate) { if (!WebConfigHelper.TrackEditionLocationUpdate) { return new EmailResult { Sent = false, ErrorMessage = "Tracking disabled." } } ; // IF EDITION START DATE IS LATER THAN NOW if (edition.HasNotStartedYet() && edition.HasCityOrCountry()) { // SEND NOTIFICATION EMAIL var recipients = emailTemplate.Recipients; if (!string.IsNullOrWhiteSpace(recipients)) { const NotificationType notificationType = NotificationType.EditionLocationUpdated; var recipientFullName = emailTemplate.RecipientFullName; var body = $"Dear {recipientFullName} ," + "<br/><br/>" + $"This is to inform you that there have been some changes to the city and/or country information for {edition.EditionName}." + @"<br/><br/> You may want to log in and double check whether this information affects the address / map location of the existing Venue location information. <br/><br/> To do so please click the button below to go to event edition's page and make the changes in Event Venue section of General Info tab shown below if needed. <br/><br/>" + $"<img src='{AzureStorageHelper.AzureStorageContainerUri}event-venue-map.png' />"; var buttonUrl = _editionHelper.GetEditionUrl(edition); return(_emailNotificationHelper.Send(edition, editionTranslation, notificationType, recipientFullName, body, recipients, buttonUrl, emailTemplate.UnsubscriptionUrl)); } } return(new EmailResult { Sent = false, ErrorMessage = "Event doesn't fit the necessary criteria for emailing." }); }
private EmailResult SendNotificationEmailForEditionNameUpdate(EditionEntity edition, EditionTranslationEntity editionTranslation, EditionMailTemplate emailTemplate) { if (!WebConfigHelper.TrackEditionNameUpdate) { return new EmailResult { Sent = false, ErrorMessage = "Tracking disabled." } } ; // ADDITIONAL RECIPIENTS if (!WebConfigHelper.IsLocal && !WebConfigHelper.IsTest) { emailTemplate.Recipients += "," + WebConfigHelper.TrackEditionNameUpdateAdditionalRecipients; } if (!string.IsNullOrWhiteSpace(emailTemplate.Recipients)) { const NotificationType notificationType = NotificationType.EditionNameUpdated; var recipientFullName = emailTemplate.RecipientFullName; var body = $"Dear {recipientFullName} ," + "<br/><br/>" + $"This is to inform you that there have been some changes to the event name information for {edition.EditionName}." + @"<br/><br/> You may want to log in and double check whether this change causes inconsistency on any information. <br/><br/> To do so please click the button below to go to event's page."; var buttonUrl = _editionHelper.GetEditionUrl(edition); return(_emailNotificationHelper.Send(edition, editionTranslation, notificationType, recipientFullName, body, emailTemplate.Recipients, buttonUrl, emailTemplate.UnsubscriptionUrl)); } return(new EmailResult { Sent = false, ErrorMessage = "Event doesn't fit the necessary criteria for emailing." }); }
public EmailResult Send(EditionEntity edition, EditionTranslationEntity editionTranslation, NotificationType notificationType, string recipientFullName, string body, string recipients, string buttonUrl, string unsubscriptionUrl) { if (string.IsNullOrWhiteSpace(recipients)) { var message = $"{notificationType} type of notification email could not be sent since edition {edition.EditionId} - {edition.EditionName} has no recipients."; return(new EmailResult { Sent = false, ErrorMessage = message }); } var sendEmail = notificationType.GetAttribute <NotificationAttribute>().SendEmail; if (sendEmail) { MvcMailMessage mailMessage = null; var webLogoUrl = EditionImageType.WebLogo.BlobFullUrl(editionTranslation); var displayDate = DateHelper.GetDisplayDate(edition.StartDate, edition.EndDate); var subject = GetSubject(edition, notificationType); subject += WebConfigHelper.IsLocal ? " " + _emailSubjectMarkForLocal : (WebConfigHelper.IsTest ? " " + _emailSubjectMarkForTest : null); var notfAttr = notificationType.GetAttribute <NotificationAttribute>(); if (notfAttr == null) { throw new Exception("Notification Attribute not found!"); } var editionMailTemplate = new EditionMailTemplate { EditionId = edition.EditionId, EventId = edition.EventId, AxEventId = edition.AxEventId, EditionName = edition.EditionName, EventName = edition.Event.MasterName, WebLogoUrl = webLogoUrl, Recipients = recipients, RecipientFullName = recipientFullName, DisplayDate = displayDate, VenueName = editionTranslation.VenueName, Subject = subject, Body = body, ButtonText = notfAttr.ButtonText, ButtonUrl = buttonUrl, UnsubscriptionUrl = unsubscriptionUrl, GuideUrl = WebConfigHelper.CedLogoUrl, PartialViewName = notfAttr.ViewName }; var mailer = new UserMailer.UserMailer(); mailMessage = mailer.Send(editionMailTemplate, notfAttr.PrivateEmail); return(new EmailResult { Sent = true, ErrorMessage = "" }); } return(new EmailResult { Sent = false, ErrorMessage = "Unknown error" }); }