/// <summary> /// Gets and bulk updates dynamic issues. Called when the "Get and bulk update issues" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool GetAndBulkUpdateDynamicIssues() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", SiteContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters var condition = new WhereCondition().WhereEquals("IssueNewsletterID", newsletter.NewsletterID); // Get the data var issues = IssueInfoProvider.GetIssues().Where(condition); if (issues.Any()) { // Loop through the individual items foreach (var issue in issues) { // Update the properties issue.IssueSubject = issue.IssueSubject.ToUpper(); // Save the changes IssueInfoProvider.SetIssueInfo(issue); } return(true); } } return(false); }
private string GetPreviewScriptForCampaign(IssueInfo issue, NewsletterInfo newsletter, IssueHelper issueHelper) { string currentSiteName = SiteContext.CurrentSiteName; var output = new StringBuilder(); var recipients = issue.GetRecipientsProvider() .GetMarketableRecipients() .TopN(MAX_PREVIEW_SUBSCRIBERS) .ToList(); if (!recipients.Any()) { return(InitializePreviewScriptForZeroSubscribers(issue, GetPreviewSubject(issue, newsletter, issueHelper, null, currentSiteName))); } output.AppendLine(InitializePreviewScript(issue, recipients.Count)); for (int index = 0; index < recipients.Count; index++) { var recipient = recipients[index]; var dummySubscriber = new SubscriberInfo { SubscriberFirstName = recipient.ContactFirstName, SubscriberLastName = recipient.ContactLastName, SubscriberEmail = recipient.ContactEmail }; output.AppendFormat("guid[{0}] = '{1}';", index, recipient.ContactGUID); output.AppendFormat("email[{0}] = '{1}';", index, recipient.ContactEmail); output.AppendFormat("subject[{0}] = {1};", index, ScriptHelper.GetString(HTMLHelper.HTMLEncode(GetPreviewSubject(issue, newsletter, issueHelper, dummySubscriber, currentSiteName)))); } return(output.ToString()); }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObject as NewsletterInfo; if (mNewsletter == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); return; } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "ManageSubscribers"); } var recipientStatusCalculator = new RecipientStatusCalculator(mNewsletter.NewsletterID); mStatusDataProvider = new ObjectTransformationDataProvider(); mStatusDataProvider.SetDefaultDataHandler((_, subscriberIds) => recipientStatusCalculator.GetStatuses(subscriberIds)); ScriptHelper.RegisterDialogScript(this); CurrentMaster.DisplayActionsPanel = true; // Initialize unigrid UniGridSubscribers.WhereCondition = "NewsletterID = " + mNewsletter.NewsletterID; UniGridSubscribers.OnAction += UniGridSubscribers_OnAction; UniGridSubscribers.OnExternalDataBound += UniGridSubscribers_OnExternalDataBound; UniGridSubscribers.ZeroRowsText = GetString("newsletter.subscribers.nodata"); UniGridSubscribers.FilteredZeroRowsText = GetString("newsletter.subscribers.noitemsfound"); // Initialize selectors and mass actions SetupSelectors(); }
/// <summary> /// Deletes dynamic issue. Called when the "Delete issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool DeleteDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", SiteContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters var condition = new WhereCondition().WhereEquals("IssueNewsletterID", newsletter.NewsletterID); // Get the data var issues = IssueInfoProvider.GetIssues().Where(condition); if (issues.Any()) { // Create object from DataRow IssueInfo deleteIssue = issues.First(); // Delete the dynamic issue IssueInfoProvider.DeleteIssueInfo(deleteIssue); return(deleteIssue != null); } } return(false); }
/// <summary> /// Logs activity for unsubscribing. /// </summary> /// <param name="sb">Subscriber (optional - can be null if subscriber ID is used)</param> /// <param name="subscriberId">Subscriber ID (optional - can be zero if subscriber object is used)</param> /// <param name="newsletterId">Newsletter ID</param> /// <param name="issueId">Issue ID</param> /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param> private void LogActivity(SubscriberInfo sb, int subscriberId, int newsletterId, int issueId, int contactId) { bool isFromContactGroup = !string.IsNullOrEmpty(sb.SubscriberType) && sb.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true); if (contactId <= 0) { contactId = ActivityTrackingHelper.GetContactID(sb); } if (sb == null) { sb = SubscriberInfoProvider.GetSubscriberInfo(subscriberId); } if (contactId > 0) { NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); Activity activity = new ActivityNewsletterUnsubscribing(sb, news, CMSContext.ActivityEnvironmentVariables); if (activity.Data != null) { activity.Data.ContactID = contactId; activity.Data.ItemDetailID = issueId; activity.Data.Value = isFromContactGroup ? "contactgroup(" + sb.SubscriberRelatedID + ")" : null; activity.Log(); } } }
/// <summary> /// Subscribes <paramref name="contact"/> to the specified <paramref name="newsletter"/> using <paramref name="subscriptionSettings"/>. /// If a given contact hasn't been saved into database yet the method does so. /// </summary> /// <param name="contact">Subscriber to be subscribed</param> /// <param name="newsletter">Newsletter to subscribe to</param> /// <param name="subscriptionSettings">Subscription configuration</param> /// <returns>True if contact was subscribed by current call, false when contact had already been subscribed.</returns> /// <exception cref="ArgumentNullException"><paramref name="contact"/> or <paramref name="newsletter"/> is null.</exception> public virtual bool Subscribe(ContactInfo contact, NewsletterInfo newsletter, NewsletterSubscriptionSettings subscriptionSettings) { if (contact == null) { throw new ArgumentNullException(nameof(contact)); } if (newsletter == null) { throw new ArgumentNullException(nameof(newsletter)); } var subscriptionService = Service.Resolve <ISubscriptionService>(); if (!subscriptionService.IsSubscribed(contact, newsletter)) { if (contact.ContactID <= 0) { ContactInfoProvider.SetContactInfo(contact); } subscriptionService.Subscribe(contact, newsletter, subscriptionSettings); return(true); } return(false); }
/// <summary> /// Gets and bulk updates dynamic issues. Called when the "Get and bulk update issues" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool GetAndBulkUpdateDynamicIssues() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Loop through the individual items foreach (DataRow issueDr in issues.Tables[0].Rows) { // Create object from DataRow IssueInfo modifyIssue = new IssueInfo(issueDr); // Update the properties modifyIssue.IssueSubject = modifyIssue.IssueSubject.ToUpper(); // Save the changes IssueInfoProvider.SetIssueInfo(modifyIssue); } return(true); } } return(false); }
/// <summary> /// Logs activity for unsubscribing. /// </summary> /// <param name="subscriber">Subscriber</param> /// <param name="newsletterId">Newsletter ID</param> /// <param name="issueId">Issue ID</param> /// <param name="contactId">Contact ID is present if the mail is sent to a contact or a contact group</param> private void LogActivity(SubscriberInfo subscriber, int newsletterId, int issueId, int contactId) { if (subscriber == null) { throw new ArgumentNullException("subscriber"); } if (contactId <= 0) { contactId = ActivityTrackingHelper.GetContactID(subscriber); } if (contactId > 0) { NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); bool isFromContactGroup = subscriber.SubscriberType.EqualsCSafe(PredefinedObjectType.CONTACTGROUP, true); bool isFromPersona = subscriber.SubscriberType.EqualsCSafe(PredefinedObjectType.PERSONA, true); Activity activity = new ActivityNewsletterUnsubscribing(subscriber, news, AnalyticsContext.ActivityEnvironmentVariables); if (activity.Data != null) { activity.Data.ContactID = contactId; activity.Data.ItemDetailID = issueId; if (isFromContactGroup) { activity.Data.Value = "contactgroup(" + subscriber.SubscriberRelatedID + ")"; } else if (isFromPersona) { activity.Data.Value = "persona(" + subscriber.SubscriberRelatedID + ")"; } activity.Log(); } } }
protected void Page_Load(object sender, EventArgs e) { // Get newsletter id from querystring newsletterId = QueryHelper.GetInteger("newsletterid", 0); // Try to get nesletter display name string newsName = string.Empty; NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); if (news != null) { newsName = news.NewsletterDisplayName; } // Initializes page title string[,] breadcrumbs = new string[2, 3]; breadcrumbs[0, 0] = GetString("Newsletter_Edit.Newsletters"); breadcrumbs[0, 1] = "~/CMSModules/Newsletters/Tools/Newsletters/Newsletter_List.aspx"; breadcrumbs[0, 2] = "newslettersContent"; breadcrumbs[1, 0] = newsName; breadcrumbs[1, 1] = string.Empty; breadcrumbs[1, 2] = string.Empty; CurrentMaster.Title.Breadcrumbs = breadcrumbs; // Initialize tabs InitalizeMenu(news); }
public override bool LoadData(ActivityInfo ai) { if ((ai == null) || (ai.ActivityType != PredefinedActivityType.NEWSLETTER_OPEN)) { return(false); } // Get newsletter name int newsletterId = ai.ActivityItemID; NewsletterInfo newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); if (newsletterInfo != null) { string subject = ValidationHelper.GetString(newsletterInfo.NewsletterDisplayName, null); ucDetails.AddRow("om.activitydetails.newsletter", subject); } // Get issue subject int issueId = ai.ActivityItemDetailID; IssueInfo issueInfo = IssueInfoProvider.GetIssueInfo(issueId); if (issueInfo != null) { string subject = ValidationHelper.GetString(issueInfo.IssueSubject, null); ucDetails.AddRow("om.activitydetails.newsletterissue", MacroSecurityProcessor.RemoveSecurityParameters(subject, true, null)); } return(ucDetails.IsDataLoaded); }
/// <summary> /// Initializes config form. /// </summary> /// <param name="newsletter">Newsletter object</param> private void GetNewsletterValues(NewsletterInfo newsletter) { txtNewsletterDisplayName.Text = newsletter.NewsletterDisplayName; txtNewsletterName.Text = newsletter.NewsletterName; txtNewsletterSenderName.Text = newsletter.NewsletterSenderName; txtNewsletterSenderEmail.Text = newsletter.NewsletterSenderEmail; txtNewsletterBaseUrl.Text = newsletter.NewsletterBaseUrl; txtNewsletterUnsubscribeUrl.Text = newsletter.NewsletterUnsubscribeUrl; txtDraftEmails.Text = newsletter.NewsletterDraftEmails; subscriptionTemplate.Value = newsletter.NewsletterSubscriptionTemplateID.ToString(); unsubscriptionTemplate.Value = newsletter.NewsletterUnsubscriptionTemplateID.ToString(); if (TrackingEnabled) { chkTrackOpenedEmails.Checked = newsletter.NewsletterTrackOpenEmails; chkTrackClickedLinks.Checked = newsletter.NewsletterTrackClickedLinks; } if (OnlineMarketingEnabled) { chkLogActivity.Checked = newsletter.NewsletterLogActivity; } chkEnableOptIn.Checked = plcOptIn.Visible = newsletter.NewsletterEnableOptIn; optInSelector.Value = newsletter.NewsletterOptInTemplateID; txtOptInURL.Text = newsletter.NewsletterOptInApprovalURL; chkSendOptInConfirmation.Checked = newsletter.NewsletterSendOptInConfirmation; }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObject as NewsletterInfo; if (mNewsletter == null) { pnlAvailability.Visible = false; return; } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "ManageTemplates"); } if (!RequestHelper.IsPostBack()) { LoadBindings(); } // Show all issue templates from current site var where = new WhereCondition() .WhereEquals("TemplateType", EmailTemplateType.Issue) .WhereEquals("TemplateSiteID", mNewsletter.NewsletterSiteID) .WhereNotEquals("TemplateID", mNewsletter.NewsletterTemplateID); usTemplates.WhereCondition = where.ToString(expand: true); usTemplates.OnSelectionChanged += usTemplates_OnSelectionChanged; }
/// <summary> /// Deletes dynamic issue. Called when the "Delete issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool DeleteDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Create object from DataRow IssueInfo deleteIssue = new IssueInfo(issues.Tables[0].Rows[0]); // Delete the dynamic issue IssueInfoProvider.DeleteIssueInfo(deleteIssue); return(deleteIssue != null); } } return(false); }
/// <summary> /// Creates static issue. Called when the "Create issue" button is pressed. /// </summary> private bool CreateStaticIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewStaticNewsletter", SiteContext.CurrentSiteID); if (newsletter != null) { // Create new static issue object IssueInfo newIssue = new IssueInfo(); // Set the properties newIssue.IssueSubject = "My new static issue"; newIssue.IssueNewsletterID = newsletter.NewsletterID; newIssue.IssueSiteID = SiteContext.CurrentSiteID; newIssue.IssueText = "<?xml version=\"1.0\" encoding=\"utf-16\"?><content><region id=\"content\">Issue text</region></content>"; newIssue.IssueUnsubscribed = 0; newIssue.IssueSentEmails = 0; newIssue.IssueTemplateID = newsletter.NewsletterTemplateID; newIssue.IssueShowInNewsletterArchive = false; // Save the static issue IssueInfoProvider.SetIssueInfo(newIssue); return(true); } return(false); }
private static string GetPreviewSubject(IssueInfo issue, NewsletterInfo newsletter, IssueHelper issueHelper, SubscriberInfo subscriber, string siteName) { // Resolve dynamic field macros ({%FirstName%}, {%LastName%}, {%Email%}) return(issueHelper.LoadDynamicFields(subscriber, newsletter, null, issue, true, siteName, null, null, null) ? issueHelper.ResolveDynamicFieldMacros(issue.IssueSubject, newsletter, issue) : null); }
protected void Page_Load(object sender, EventArgs e) { // Check read permission for newsletters if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Newsletter", "Read")) { IssueInfo iss = null; int issueId = QueryHelper.GetInteger("IssueId", 0); if (issueId > 0) { // Get newsletter issue by ID iss = IssueInfoProvider.GetIssueInfo(issueId); } else { // Get newsletter issue by GUID and site ID Guid issueGuid = QueryHelper.GetGuid("IssueGUID", Guid.Empty); iss = IssueInfoProvider.GetIssueInfo(issueGuid, SiteContext.CurrentSiteID); } if ((iss != null) && (iss.IssueSiteID == SiteContext.CurrentSiteID)) { // Get newsletter NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(iss.IssueNewsletterID); Response.Clear(); Response.Write(IssueInfoProvider.GetEmailBody(iss, news, null, null, false, SiteContext.CurrentSiteName, null, null, null)); Response.Flush(); RequestHelper.EndResponse(); } } }
public override bool LoadData(ActivityInfo ai) { if ((ai == null) || (ai.ActivityType != PredefinedActivityType.NEWSLETTER_CLICKTHROUGH)) { return(false); } // Get newsletter name int newsletterId = ai.ActivityItemID; NewsletterInfo newsletterInfo = NewsletterInfo.Provider.Get(newsletterId); if (newsletterInfo != null) { ucDetails.AddRow("om.activitydetails.newsletter", newsletterInfo.NewsletterDisplayName); } // Get issue subject int issueId = ai.ActivityItemDetailID; IssueInfo issueInfo = IssueInfo.Provider.Get(issueId); if (issueInfo != null) { ucDetails.AddRow("om.activitydetails.newsletterissue", issueInfo.IssueDisplayName); } string targetLink = ai.ActivityURL; ucDetails.AddRow("om.activitydetails.newstargetlink", GetLink(targetLink, targetLink), false); return(ucDetails.IsDataLoaded); }
private void InitializeSubscribersForCampaign(IssueInfo issue, NewsletterInfo newsletter) { var recipients = issue.GetRecipientsProvider() .GetMarketableRecipients() .TopN(MAX_PREVIEW_SUBSCRIBERS) .ToList(); if (recipients.Count > 0) { for (int index = 0; index < recipients.Count; index++) { var recipient = recipients[index]; var subscriber = recipient.ToContactSubscriber(); var emailViewer = new EmailViewer(issue, newsletter, subscriber, true); emails.Add(HttpUtility.UrlEncode(recipient.ContactEmail)); subjects.Add(GetEncodedSubscriberSubject(emailViewer)); preheaders.Add(GetEncodedSubscriberPreheader(emailViewer)); drpSubscribers.Items.Add(new ListItem(recipient.ContactEmail, index.ToString())); } } else { DisableSubscribersDropDownList(); var emailViewer = new EmailViewer(issue, newsletter, null, true); InitializeZeroSubscribers(emailViewer.GetSubject(), emailViewer.GetPreheader()); } }
private void SetLabelValues(IssueInfo issue, NewsletterInfo newsletter) { var senderRetriever = new SenderRetriever(issue, newsletter); lblFromValue.Text = HTMLHelper.HTMLEncode(senderRetriever.GetSenderName()); lblFromEmailValue.Text = senderRetriever.GetSenderEmail(); }
protected void Page_Load(object sender, EventArgs e) { // Get issue object int issueId = QueryHelper.GetInteger("issueid", 0); IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId); if (issue != null) { // Get newsletter object NewsletterInfo news = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if (news != null) { if (news.NewsletterType == NewsletterType.Dynamic) { // Only send page is allowed for dynamic newsletters issueContentUrl = "Newsletter_Issue_Send.aspx?issueid=" + issueId.ToString(); } else { issueContentUrl = "Newsletter_Issue_Edit.aspx?issueid=" + issueId.ToString(); } } } if (string.IsNullOrEmpty(issueContentUrl)) { issueContentUrl = "Newsletter_Issue_Edit.aspx"; } }
public override bool LoadData(ActivityInfo ai) { if ((ai == null) || (ai.ActivityType != PredefinedActivityType.NEWSLETTER_OPEN)) { return(false); } // Get newsletter name int newsletterId = ai.ActivityItemID; NewsletterInfo newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); if (newsletterInfo != null) { ucDetails.AddRow("om.activitydetails.newsletter", newsletterInfo.NewsletterDisplayName); } // Get issue subject int issueId = ai.ActivityItemDetailID; IssueInfo issueInfo = IssueInfoProvider.GetIssueInfo(issueId); if (issueInfo != null) { ucDetails.AddRow("om.activitydetails.newsletterissue", issueInfo.IssueDisplayName); } return(ucDetails.IsDataLoaded); }
protected void Page_Load(object sender, EventArgs e) { // Reset master page content CSS class CurrentMaster.PanelContent.CssClass = string.Empty; // Get edited issue object and check its existence IssueInfo issue = (IssueInfo)EditedObject; EditedObject = issue; // Get newsletter and check its existence newsletter = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if ((newsletter != null) && (newsletter.NewsletterType == NewsletterType.Dynamic)) { ShowError(GetString("Newsletter_Issue_Edit.CannotBeEdited")); editElem.StopProcessing = true; editElem.Visible = false; return; } // Get variant issue ID if A/B testing is ON int issueId = InitVariantSlider(issue.IssueID); // Initialize edit control editElem.IssueID = issueId; editElem.NewsletterID = issue.IssueNewsletterID; editElem.IsDialogMode = false; InitHeaderActions(issueId); }
/// <summary> /// Creates static newsletter. Called when the "Create newsletter" button is pressed. /// </summary> private bool CreateStaticNewsletter() { EmailTemplateInfo subscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewSubscriptionTemplate", SiteContext.CurrentSiteID); EmailTemplateInfo unsubscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewUnsubscriptionTemplate", SiteContext.CurrentSiteID); EmailTemplateInfo myNewIssueTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewIssueTemplate", SiteContext.CurrentSiteID); if ((subscriptionTemplate != null) && (unsubscriptionTemplate != null) && (myNewIssueTemplate != null)) { // Create new static newsletter object NewsletterInfo newNewsletter = new NewsletterInfo(); // Set the properties newNewsletter.NewsletterDisplayName = "My new static newsletter"; newNewsletter.NewsletterName = "MyNewStaticNewsletter"; newNewsletter.NewsletterType = NewsletterType.TemplateBased; newNewsletter.NewsletterSubscriptionTemplateID = subscriptionTemplate.TemplateID; newNewsletter.NewsletterUnsubscriptionTemplateID = unsubscriptionTemplate.TemplateID; newNewsletter.NewsletterTemplateID = myNewIssueTemplate.TemplateID; newNewsletter.NewsletterSenderName = "Sender name"; newNewsletter.NewsletterSenderEmail = "*****@*****.**"; newNewsletter.NewsletterSiteID = SiteContext.CurrentSiteID; // Save the static newsletter NewsletterInfoProvider.SetNewsletterInfo(newNewsletter); return(true); } return(false); }
/// <summary> /// Gets and bulk updates dynamic newsletters. Called when the "Get and bulk update newsletters" button is pressed. /// Expects the CreateDynamicNewsletter method to be run first. /// </summary> private bool GetAndBulkUpdateDynamicNewsletters() { // Prepare the parameters string where = "NewsletterName LIKE N'MyNewDynamicNewsletter%'"; // Get the data DataSet newsletters = NewsletterInfoProvider.GetNewsletters(where, null, 0, null); if (!DataHelper.DataSourceIsEmpty(newsletters)) { // Loop through the individual items foreach (DataRow newsletterDr in newsletters.Tables[0].Rows) { // Create object from DataRow NewsletterInfo modifyNewsletter = new NewsletterInfo(newsletterDr); // Update the properties modifyNewsletter.NewsletterDisplayName = modifyNewsletter.NewsletterDisplayName.ToUpper(); // Save the changes NewsletterInfoProvider.SetNewsletterInfo(modifyNewsletter); } return(true); } return(false); }
/// <summary> /// Creates dynamic newsletter. Called when the "Create newsletter" button is pressed. /// </summary> private bool CreateDynamicNewsletter() { EmailTemplateInfo subscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewSubscriptionTemplate", SiteContext.CurrentSiteID); EmailTemplateInfo unsubscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewUnsubscriptionTemplate", SiteContext.CurrentSiteID); if ((subscriptionTemplate != null) && (unsubscriptionTemplate != null)) { // Create new dynamic newsletter object NewsletterInfo newNewsletter = new NewsletterInfo(); // Set the properties newNewsletter.NewsletterDisplayName = "My new dynamic newsletter"; newNewsletter.NewsletterName = "MyNewDynamicNewsletter"; newNewsletter.NewsletterType = NewsletterType.Dynamic; newNewsletter.NewsletterSubscriptionTemplateID = subscriptionTemplate.TemplateID; newNewsletter.NewsletterUnsubscriptionTemplateID = unsubscriptionTemplate.TemplateID; newNewsletter.NewsletterSenderName = "Sender name"; newNewsletter.NewsletterSenderEmail = "*****@*****.**"; newNewsletter.NewsletterDynamicURL = "http://www.google.com"; newNewsletter.NewsletterDynamicSubject = "My new dynamic issue"; newNewsletter.NewsletterSiteID = SiteContext.CurrentSiteID; // Save the dynamic newsletter NewsletterInfoProvider.SetNewsletterInfo(newNewsletter); return(true); } return(false); }
/// <summary> /// Gets and updates dynamic issue. Called when the "Get and update issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool GetAndUpdateDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", CMSContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters string where = "IssueNewsletterID = " + newsletter.NewsletterID; // Get the data DataSet issues = IssueInfoProvider.GetIssues(where, null); if (!DataHelper.DataSourceIsEmpty(issues)) { // Create object from DataRow IssueInfo updateIssue = new IssueInfo(issues.Tables[0].Rows[0]); if (updateIssue != null) { // Update the properties updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower(); // Save the changes IssueInfoProvider.SetIssueInfo(updateIssue); return(true); } } } return(false); }
/// <summary> /// Gets and updates dynamic issue. Called when the "Get and update issue" button is pressed. /// Expects the CreateDynamicIssue method to be run first. /// </summary> private bool GetAndUpdateDynamicIssue() { // Get the newsletter NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("MyNewDynamicNewsletter", SiteContext.CurrentSiteID); if (newsletter != null) { // Prepare the parameters var condition = new WhereCondition().WhereEquals("IssueNewsletterID", newsletter.NewsletterID); // Get the data var issues = IssueInfoProvider.GetIssues().Where(condition); if (issues.Any()) { // Create object from DataRow IssueInfo updateIssue = issues.First(); if (updateIssue != null) { // Update the properties updateIssue.IssueSubject = updateIssue.IssueSubject.ToLower(); // Save the changes IssueInfoProvider.SetIssueInfo(updateIssue); return(true); } } } return(false); }
public ActionResult Subscribe(NewsletterSubscribeViewModel model) { if (!ModelState.IsValid) { // If the subscription data is not valid, displays the subscription form with error messages return(View(model)); } // Gets the default Kentico contact provider IContactProvider contactProvider = Service <IContactProvider> .Entry(); // Either gets an existing contact by email or creates a new contact object with the given email ContactInfo contact = contactProvider.GetContactForSubscribing(model.Email); // Gets a newsletter // Fill in the code name of your newsletter object in Kentico NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo("SampleNewsletter", SiteContext.CurrentSiteID); // Prepares settings that configure the subscription behavior var subscriptionSettings = new NewsletterSubscriptionSettings() { RemoveAlsoUnsubscriptionFromAllNewsletters = true, // Subscription removes the given email address from the global opt-out list for all marketing emails (if present) SendConfirmationEmail = true, // Allows sending of confirmation emails for the subscription AllowOptIn = true // Allows handling of double opt-in subscription for newsletters that have it enabled }; // Subscribes the contact with the specified email address to the given newsletter SubscriptionService.Subscribe(contact, newsletter, subscriptionSettings); // Passes information to the view, indicating whether the newsletter requires double opt-in for subscription model.RequireDoubleOptIn = newsletter.NewsletterEnableOptIn; // Displays a view to inform the user that the subscription was successful return(View("SubscribeSuccess", model)); }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObject as NewsletterInfo; if (mNewsletter == null) { pnlAvailability.Visible = false; return; } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "ManageTemplates"); } if (!RequestHelper.IsPostBack()) { LoadBindings(); } // Show all issue templates from current site var where = new WhereCondition() .WhereEquals("TemplateType", EmailTemplateType.Issue) .WhereEquals("TemplateSiteID", mNewsletter.NewsletterSiteID) .WhereNotEquals("TemplateID", mNewsletter.NewsletterTemplateID); usTemplates.WhereCondition = where.ToString(expand: true); usTemplates.OnSelectionChanged += usTemplates_OnSelectionChanged; }
protected void Page_Load(object sender, EventArgs e) { // Get issue ID from querystring issueId = QueryHelper.GetInteger("issueid", 0); // Get newsletter issue and check its existence IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId); EditedObject = issue; string infoMessage = null; bool isABTest = issue.IssueIsABTest; bool sendingIssueAllowed = false; sendElem.Visible = !isABTest; sendVariant.Visible = isABTest; if (!isABTest) { sendElem.IssueID = issueId; sendElem.NewsletterID = issue.IssueNewsletterID; bool isSent = (issue.IssueMailoutTime != DateTimeHelper.ZERO_TIME) && (issue.IssueMailoutTime < DateTime.Now); infoMessage = (isSent ? GetString("Newsletter_Issue_Header.AlreadySent") : GetString("Newsletter_Issue_Header.NotSentYet")); // If resending is disabled check that the issue has 'Idle' status newsletter = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if (newsletter != null) { sendingIssueAllowed = newsletter.NewsletterEnableResending || issue.IssueStatus == IssueStatusEnum.Idle; } } else { sendVariant.StopProcessing = (issueId <= 0); sendVariant.IssueID = issueId; sendVariant.OnChanged -= new EventHandler(sendVariant_OnChanged); sendVariant.OnChanged += new EventHandler(sendVariant_OnChanged); sendVariant.ReloadData(!RequestHelper.IsPostBack()); infoMessage = sendVariant.InfoMessage; sendingIssueAllowed = sendVariant.SendingAllowed; } // Display additional information if (!String.IsNullOrEmpty(infoMessage)) { ShowInformationInternal(infoMessage); } InitHeaderActions(isABTest && (issue.IssueStatus != IssueStatusEnum.Finished), sendingIssueAllowed); string scriptBlock = @"function RefreshPage() {{ document.location.replace(document.location); }}"; ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true); if (!RequestHelper.IsPostBack() && (QueryHelper.GetInteger("sent", 0) == 1)) { ShowConfirmation(GetString("Newsletter_Send.SuccessfullySent")); } }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObjectParent as NewsletterInfo; if (mNewsletter == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "Read"); } mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(CurrentSiteName); mTrackingEnabled = NewsletterHelper.IsTrackingAvailable(); if (mTrackingEnabled && !mBounceMonitoringEnabled) { ShowInformation(GetString("newsletter.viewadditionalstatsmessage")); } ScriptHelper.RegisterTooltip(this); // Initialize unigrid UniGrid.WhereCondition = String.Format("IssueNewsletterID={0} AND IssueVariantOfIssueID IS NULL", mNewsletter.NewsletterID); UniGrid.ZeroRowsText = GetString("Newsletter_Issue_List.NoIssuesFound"); UniGrid.OnAction += uniGrid_OnAction; UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; // Initialize header actions InitHeaderActions(); // Prepare data for listing // Group clicked link records by IssueID with Columns LinkIssueID, UniqueUserClicks, VariantParent (to calculate clicked links through all variant) mClickedLinksSummary = ClickedLinkInfoProvider.GetClickedLinks() .Columns(new QueryColumn("LinkIssueID"), new AggregatedColumn(AggregationType.Count, "DISTINCT(ClickedLinkEmail)").As("UniqueUserClicks")) .Source(s => s.Join <LinkInfo>("ClickedLinkNewsletterLinkID", "LinkID")) .GroupBy("LinkIssueID"); // Prepare variant summaries mVariantIssueSummaries = IssueInfoProvider.GetIssues() .Columns(new QueryColumn("IssueVariantOfIssueID"), new AggregatedColumn(AggregationType.Sum, "IssueOpenedEmails").As("OpenedEmailsSum")) .WhereEquals("IssueNewsletterID", mNewsletter.NewsletterID) .GroupBy("IssueVariantOfIssueID") .Having("IssueVariantOfIssueID IS NOT NULL"); // AB Variant issues for current newsletter mVariantIssues = IssueInfoProvider.GetIssues() .Columns("IssueID", "IssueVariantOfIssueID") .WhereEquals("IssueNewsletterID", mNewsletter.NewsletterID) .WhereNotNull("IssueVariantOfIssueID"); AddBrokenEmailUrlNotifier(mNewsletter, lblUrlWarning); }
protected void Page_Load(object sender, EventArgs e) { // Get issue ID from querystring issueId = QueryHelper.GetInteger("issueid", 0); // Get newsletter issue and check its existence IssueInfo issue = IssueInfoProvider.GetIssueInfo(issueId); EditedObject = issue; string infoMessage = null; bool isABTest = issue.IssueIsABTest; bool sendingIssueAllowed = false; sendElem.Visible = !isABTest; sendVariant.Visible = isABTest; if (!isABTest) { sendElem.IssueID = issueId; sendElem.NewsletterID = issue.IssueNewsletterID; bool isSent = (issue.IssueMailoutTime != DateTimeHelper.ZERO_TIME) && (issue.IssueMailoutTime < DateTime.Now); infoMessage = (isSent ? GetString("Newsletter_Issue_Header.AlreadySent") : GetString("Newsletter_Issue_Header.NotSentYet")); // If resending is disabled check that the issue has 'Idle' status newsletter = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if (newsletter != null) { sendingIssueAllowed = newsletter.NewsletterEnableResending || issue.IssueStatus == IssueStatusEnum.Idle; } } else { sendVariant.StopProcessing = (issueId <= 0); sendVariant.IssueID = issueId; sendVariant.OnChanged -= new EventHandler(sendVariant_OnChanged); sendVariant.OnChanged += new EventHandler(sendVariant_OnChanged); sendVariant.ReloadData(!RequestHelper.IsPostBack()); infoMessage = sendVariant.InfoMessage; sendingIssueAllowed = sendVariant.SendingAllowed; } // Display additional information if (!String.IsNullOrEmpty(infoMessage)) { ShowInformationInternal(infoMessage); } InitHeaderActions(isABTest && (issue.IssueStatus != IssueStatusEnum.Finished), sendingIssueAllowed); string scriptBlock = @"function RefreshPage() {{ document.location.replace(document.location); }}"; ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true); if (!RequestHelper.IsPostBack() && (QueryHelper.GetInteger("sent", 0) == 1)) { ShowConfirmation(GetString("Newsletter_Send.SuccessfullySent")); } }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObject as NewsletterInfo; if (mNewsletter == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "Read"); } mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(CurrentSiteName); mTrackingEnabled = NewsletterHelper.IsTrackingAvailable(); if (mTrackingEnabled && !mBounceMonitoringEnabled) { ShowInformation(GetString("newsletter.viewadditionalstatsmessage")); } ScriptHelper.RegisterTooltip(this); // Initialize unigrid UniGrid.WhereCondition = String.Format("IssueNewsletterID={0} AND IssueVariantOfIssueID IS NULL", mNewsletter.NewsletterID); UniGrid.ZeroRowsText = GetString("Newsletter_Issue_List.NoIssuesFound"); UniGrid.OnAction += uniGrid_OnAction; UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; // Initialize header actions InitHeaderActions(); // Prepare data for listing // Group clicked link records by IssueID with Columns LinkIssueID, UniqueUserClicks, VariantParent (to calculate clicked links through all variant) mClickedLinksSummary = ClickedLinkInfoProvider.GetClickedLinks() .Columns(new QueryColumn("LinkIssueID"), new AggregatedColumn(AggregationType.Count, "DISTINCT(ClickedLinkEmail)").As("UniqueUserClicks")) .Source(s => s.Join<LinkInfo>("ClickedLinkNewsletterLinkID", "LinkID")) .GroupBy("LinkIssueID"); // Prepare variant summaries mVariantIssueSummaries = IssueInfoProvider.GetIssues() .Columns(new QueryColumn("IssueVariantOfIssueID"), new AggregatedColumn(AggregationType.Sum, "IssueOpenedEmails").As("OpenedEmailsSum")) .WhereEquals("IssueNewsletterID", mNewsletter.NewsletterID) .GroupBy("IssueVariantOfIssueID") .Having("IssueVariantOfIssueID IS NOT NULL"); // AB Variant issues for current newsletter mVariantIssues = IssueInfoProvider.GetIssues() .Columns("IssueID", "IssueVariantOfIssueID") .WhereEquals("IssueNewsletterID", mNewsletter.NewsletterID) .WhereNotNull("IssueVariantOfIssueID"); }
protected void Page_Load(object sender, EventArgs e) { newsletterId = QueryHelper.GetInteger("newsletterId", 0); if (newsletterId <= 0) { pnlAvailability.Visible = false; return; } EditedObject = newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); if (!RequestHelper.IsPostBack()) { LoadBindings(); } // Show all issue templates from current site usTemplates.WhereCondition = String.Format("TemplateType='{0}' AND TemplateSiteID={1} AND TemplateID<>{2}", SqlHelperClass.GetSafeQueryString(EmailTemplateType.Issue), newsletterInfo.NewsletterSiteID, newsletterInfo.NewsletterTemplateID); usTemplates.OnSelectionChanged += usTemplates_OnSelectionChanged; }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObject as NewsletterInfo; if (mNewsletter == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "Read"); } mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(CurrentSiteName); mOnlineMarketingEnabled = NewsletterHelper.OnlineMarketingAvailable(CurrentSiteName); mTrackingEnabled = NewsletterHelper.IsTrackingAvailable(); mABTestEnabled = NewsletterHelper.IsABTestingAvailable(); ScriptHelper.RegisterDialogScript(this); string scriptBlock = string.Format(@" function RefreshPage() {{ document.location.replace(document.location); }} function NewItem(id) {{ modalDialog('{0}?parentobjectid=' + id, 'NewsletterNewIssue', screen.availWidth - 10, screen.availHeight - 80); }} function ShowOpenedBy(id) {{ modalDialog('{1}?objectid=' + id, 'NewsletterIssueOpenedBy', '900px', '700px'); return false; }} function ViewClickedLinks(id) {{ modalDialog('{2}?objectid=' + id, 'NewsletterTrackedLinks', '900px', '700px'); return false; }}", ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_New.aspx"), ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_OpenedBy.aspx"), ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_TrackedLinks.aspx")); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true); // Initialize unigrid UniGrid.WhereCondition = String.Format("IssueNewsletterID={0} AND IssueVariantOfIssueID IS NULL", mNewsletter.NewsletterID); UniGrid.ZeroRowsText = GetString("Newsletter_Issue_List.NoIssuesFound"); UniGrid.OnAction += uniGrid_OnAction; UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; // Initialize header actions InitHeaderActions(); }
protected void Page_Load(object sender, EventArgs e) { newsletterId = QueryHelper.GetInteger("newsletterid", 0); if (newsletterId == 0) { RequestHelper.EndResponse(); } // Get newsletter object and check its existence mNewsletter = NewsletterInfoProvider.GetNewsletterInfo(newsletterId); EditedObject = mNewsletter; string siteName = CMSContext.CurrentSiteName; mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(siteName); mOnlineMarketingEnabled = NewsletterHelper.OnlineMarketingAvailable(siteName); mTrackingEnabled = NewsletterHelper.IsTrackingAvailable(); mABTestEnabled = NewsletterHelper.IsABTestingAvailable(); ScriptHelper.RegisterDialogScript(this); string scriptBlock = string.Format(@" function RefreshPage() {{ document.location.replace(document.location); }} function NewItem(id) {{ modalDialog('{0}?newsletterid=' + id, 'NewsletterNewIssue', screen.availWidth - 10, screen.availHeight - 80); }} function ShowOpenedBy(id) {{ modalDialog('{1}?issueid=' + id, 'NewsletterIssueOpenedBy', '900px', '700px'); return false; }} function ViewClickedLinks(id) {{ modalDialog('{2}?issueid=' + id, 'NewsletterTrackedLinks', '900px', '700px'); return false; }}", ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_New.aspx"), ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_OpenedBy.aspx"), ResolveUrl(@"~\CMSModules\Newsletters\Tools\Newsletters\Newsletter_Issue_TrackedLinks.aspx")); ScriptHelper.RegisterClientScriptBlock(this, GetType(), "Actions", scriptBlock, true); // Initialize unigrid UniGrid.WhereCondition = String.Format("IssueNewsletterID={0} AND IssueVariantOfIssueID IS NULL", newsletterId); UniGrid.ZeroRowsText = GetString("Newsletter_Issue_List.NoIssuesFound"); UniGrid.OnAction += uniGrid_OnAction; UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; // Initialize header actions InitHeaderActions(); }
/// <summary> /// Initializes newsletter menu. /// </summary> /// <param name="news">Newsletter object</param> protected void InitalizeMenu(NewsletterInfo news) { if (news != null) { InitTabs("newsletterContent"); SetTab(0, GetString("Newsletter_Header.Issues"), "Newsletter_Issue_List.aspx?newsletterid=" + newsletterId, "SetHelpTopic('helpTopic', 'issues_tab');"); SetTab(1, GetString("Newsletter_Header.Configuration"), "Newsletter_Configuration.aspx?newsletterid=" + newsletterId, "SetHelpTopic('helpTopic', 'configuration_tab');"); SetTab(2, GetString("Newsletter_Header.Subscribers"), "Newsletter_Subscribers.aspx?newsletterid=" + newsletterId, "SetHelpTopic('helpTopic', 'subscribers_tab');"); if (news.NewsletterType == NewsletterType.Dynamic) { SetTab(3, GetString("Newsletter_Header.Send"), "Newsletter_Send.aspx?newsletterid=" + newsletterId, "SetHelpTopic('helpTopic', 'send_tab');"); } else if (news.NewsletterType == NewsletterType.TemplateBased) { SetTab(3, GetString("newsletter.issuetemplates"), "Tab_Templates.aspx?newsletterid=" + newsletterId, "SetHelpTopic('helpTopic','newsletter_templates')"); } if (ValidationHelper.GetInteger(Request.QueryString["saved"], 0) > 0) { // User was redirected from Newsletter_New.aspx => show 'configuration' tab CurrentMaster.Tabs.SelectedTab = 1; } } }
/// <summary> /// Initializes config form. /// </summary> /// <param name="newsletter">Newsletter object</param> private void GetNewsletterValues(NewsletterInfo newsletter) { txtNewsletterDisplayName.Text = newsletter.NewsletterDisplayName; txtNewsletterName.Text = newsletter.NewsletterName; txtNewsletterSenderName.Text = newsletter.NewsletterSenderName; txtNewsletterSenderEmail.Text = newsletter.NewsletterSenderEmail; txtNewsletterBaseUrl.Text = newsletter.NewsletterBaseUrl; txtNewsletterUnsubscribeUrl.Text = newsletter.NewsletterUnsubscribeUrl; txtDraftEmails.Text = newsletter.NewsletterDraftEmails; chkUseEmailQueue.Checked = newsletter.NewsletterUseEmailQueue; chkEnableResending.Checked = newsletter.NewsletterEnableResending; subscriptionTemplate.Value = newsletter.NewsletterSubscriptionTemplateID.ToString(); unsubscriptionTemplate.Value = newsletter.NewsletterUnsubscriptionTemplateID.ToString(); if (TrackingEnabled) { chkTrackOpenedEmails.Checked = newsletter.NewsletterTrackOpenEmails; chkTrackClickedLinks.Checked = newsletter.NewsletterTrackClickedLinks; } if (OnlineMarketingEnabled) { chkLogActivity.Checked = newsletter.NewsletterLogActivity; } chkEnableOptIn.Checked = plcOptIn.Visible = newsletter.NewsletterEnableOptIn; optInSelector.Value = newsletter.NewsletterOptInTemplateID; txtOptInURL.Text = newsletter.NewsletterOptInApprovalURL; chkSendOptInConfirmation.Checked = newsletter.NewsletterSendOptInConfirmation; }
/// <summary> /// Returns existing or new task info object. /// </summary> /// <param name="newsletterObj">Newsletter object</param> private static TaskInfo GetDynamicNewsletterTask(NewsletterInfo newsletterObj) { return TaskInfoProvider.GetTaskInfo(newsletterObj.NewsletterDynamicScheduledTaskID) ?? CreateDynamicNewsletterTask(newsletterObj); }
/// <summary> /// Creates new task info object for given newsletter. /// </summary> /// <param name="newsletterObj">Newsletter object</param> private static TaskInfo CreateDynamicNewsletterTask(NewsletterInfo newsletterObj) { return new TaskInfo { TaskAssemblyName = "CMS.Newsletters", TaskClass = "CMS.Newsletters.DynamicNewsletterSender", TaskEnabled = true, TaskLastResult = string.Empty, TaskSiteID = SiteContext.CurrentSiteID, TaskData = newsletterObj.NewsletterGUID.ToString(), TaskType = ScheduledTaskTypeEnum.System }; }
/// <summary> /// Gets and bulk updates static newsletters. Called when the "Get and bulk update newsletters" button is pressed. /// Expects the CreateStaticNewsletter method to be run first. /// </summary> private bool GetAndBulkUpdateStaticNewsletters() { // Prepare the parameters string where = "NewsletterName LIKE N'MyNewStaticNewsletter%'"; // Get the data DataSet newsletters = NewsletterInfoProvider.GetNewsletters(where, null, 0, null); if (!DataHelper.DataSourceIsEmpty(newsletters)) { // Loop through the individual items foreach (DataRow newsletterDr in newsletters.Tables[0].Rows) { // Create object from DataRow NewsletterInfo modifyNewsletter = new NewsletterInfo(newsletterDr); // Update the properties modifyNewsletter.NewsletterDisplayName = modifyNewsletter.NewsletterDisplayName.ToUpper(); // Save the changes NewsletterInfoProvider.SetNewsletterInfo(modifyNewsletter); } return true; } return false; }
/// <summary> /// Creates static newsletter. Called when the "Create newsletter" button is pressed. /// </summary> private bool CreateStaticNewsletter() { EmailTemplateInfo subscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewSubscriptionTemplate", CMSContext.CurrentSiteID); EmailTemplateInfo unsubscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewUnsubscriptionTemplate", CMSContext.CurrentSiteID); EmailTemplateInfo myNewIssueTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewIssueTemplate", CMSContext.CurrentSiteID); if ((subscriptionTemplate != null) && (unsubscriptionTemplate != null) && (myNewIssueTemplate != null)) { // Create new static newsletter object NewsletterInfo newNewsletter = new NewsletterInfo(); // Set the properties newNewsletter.NewsletterDisplayName = "My new static newsletter"; newNewsletter.NewsletterName = "MyNewStaticNewsletter"; newNewsletter.NewsletterType = NewsletterType.TemplateBased; newNewsletter.NewsletterSubscriptionTemplateID = subscriptionTemplate.TemplateID; newNewsletter.NewsletterUnsubscriptionTemplateID = unsubscriptionTemplate.TemplateID; newNewsletter.NewsletterTemplateID = myNewIssueTemplate.TemplateID; newNewsletter.NewsletterSenderName = "Sender name"; newNewsletter.NewsletterSenderEmail = "*****@*****.**"; newNewsletter.NewsletterSiteID = CMSContext.CurrentSiteID; // Save the static newsletter NewsletterInfoProvider.SetNewsletterInfo(newNewsletter); return true; } return false; }
/// <summary> /// Performs action on given subscriber. /// </summary> /// <param name="newsletter">Newsletter info</param> /// <param name="actionName">Name of action</param> private void DoSubscriberAction(NewsletterInfo newsletter, string actionName) { switch (actionName.ToUpperInvariant()) { // Renew subscription case SUBSCRIBE: var subscriberNewsletterInfo = SubscriberNewsletterInfoProvider.GetSubscriberNewsletterInfo(mSubscriberId, newsletter.NewsletterID); if (subscriberNewsletterInfo.SubscriptionEnabled) { return; } bool requireDoubleOptIn = chkRequireOptIn.Checked && newsletter.NewsletterEnableOptIn; SubscriberInfoProvider.RenewSubscription(mSubscriberId, newsletter.NewsletterID, chkSendConfirmation.Checked && !requireDoubleOptIn); bool approved = true; // Check if double opt-in is enabled and if confirmation e-mail checkbox was checked if (requireDoubleOptIn) { IssueInfoProvider.SendDoubleOptInEmail(mSubscriberId, newsletter.NewsletterID); approved = false; } SubscriberNewsletterInfoProvider.SetApprovalStatus(mSubscriberId, newsletter.NewsletterID, approved); break; // Unsubscribe case UNSUBSCRIBE: SubscriberInfoProvider.Unsubscribe(mSubscriberId, newsletter.NewsletterID, chkSendConfirmation.Checked); break; // Remove subscription case REMOVE: SubscriberInfoProvider.DeleteSubscription(mSubscriberId, newsletter.NewsletterID, chkSendConfirmation.Checked); break; // Approve subscription case APPROVE: SubscriberNewsletterInfoProvider.ApproveSubscription(mSubscriberId, newsletter.NewsletterID); break; } }
protected void Page_Load(object sender, EventArgs e) { // Normal messages must be bellow the information label MessagesPlaceHolder = plcMess; // Get newsletter issue and check its existence IssueInfo issue = EditedObject as IssueInfo; if (issue == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!issue.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(issue.TypeInfo.ModuleName, "AuthorIssues"); } string infoMessage; bool isABTest = issue.IssueIsABTest; bool sendingIssueAllowed = false; sendElem.Visible = !isABTest; sendVariant.Visible = isABTest; if (!isABTest) { sendElem.IssueID = issue.IssueID; sendElem.NewsletterID = issue.IssueNewsletterID; bool isSent = (issue.IssueMailoutTime != DateTimeHelper.ZERO_TIME) && (issue.IssueMailoutTime < DateTime.Now); infoMessage = (isSent ? GetString("Newsletter_Issue_Header.AlreadySent") : GetString("Newsletter_Issue_Header.NotSentYet")); // If resending is disabled check that the issue has 'Idle' status newsletter = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if (newsletter != null) { sendingIssueAllowed = newsletter.NewsletterEnableResending || (issue.IssueStatus == IssueStatusEnum.Idle) || (issue.IssueStatus == IssueStatusEnum.ReadyForSending); } } else { sendVariant.StopProcessing = (issue.IssueID <= 0); sendVariant.IssueID = issue.IssueID; sendVariant.OnChanged -= sendVariant_OnChanged; sendVariant.OnChanged += sendVariant_OnChanged; sendVariant.ReloadData(!RequestHelper.IsPostBack()); infoMessage = sendVariant.InfoMessage; sendingIssueAllowed = sendVariant.SendingAllowed; } // Display additional information if (!String.IsNullOrEmpty(infoMessage)) { ShowInformationInternal(infoMessage); } InitHeaderActions(isABTest && (issue.IssueStatus != IssueStatusEnum.Finished), sendingIssueAllowed); string scriptBlock = @"function RefreshPage() {{ document.location.replace(document.location); }}"; ScriptHelper.RegisterClientScriptBlock(this, GetType(), "RefreshActions", scriptBlock, true); if (!RequestHelper.IsPostBack() && (QueryHelper.GetInteger("sent", 0) == 1)) { ShowConfirmation(GetString("Newsletter_Send.SuccessfullySent")); } }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObject as NewsletterInfo; if (mNewsletter == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "ManageSubscribers"); } ScriptHelper.RegisterDialogScript(this); CurrentMaster.DisplayActionsPanel = true; chkRequireOptIn.CheckedChanged += chkRequireOptIn_CheckedChanged; string currentSiteName = SiteContext.CurrentSiteName; mBounceLimit = NewsletterHelper.BouncedEmailsLimit(currentSiteName); mBounceInfoAvailable = NewsletterHelper.MonitorBouncedEmails(currentSiteName); // Check if newsletter enables double opt-in if (!mNewsletter.NewsletterEnableOptIn) { chkRequireOptIn.Visible = false; } if (!RequestHelper.IsPostBack()) { chkSendConfirmation.Checked = false; } // Initialize unigrid UniGridSubscribers.WhereCondition = "NewsletterID = " + mNewsletter.NewsletterID; UniGridSubscribers.OnAction += UniGridSubscribers_OnAction; UniGridSubscribers.OnExternalDataBound += UniGridSubscribers_OnExternalDataBound; // Initialize selectors and mass actions SetupSelectors(); }
/// <summary> /// Creates and sends unsubscription e-mail. /// </summary> /// <param name="subscriber">Subscriber to be unsubscribed</param> /// <param name="news">Newsletter object</param> /// <param name="siteName">Name of site that subscriber is being unsubscribed from</param> protected void SendUnsubscriptionRequest(SubscriberInfo subscriber, NewsletterInfo news, string siteName) { var emailTemplate = EmailTemplateProvider.GetEmailTemplate("newsletter.unsubscriptionrequest", siteName); if (emailTemplate == null) { EventLogProvider.LogEvent(EventType.ERROR, "UnsubscriptionRequest", "Unsubscription request e-mail template is missing."); return; } string body = emailTemplate.TemplateText; string plainBody = emailTemplate.TemplatePlainText; // Resolve newsletter macros (first name, last name etc.) var issueHelper = new IssueHelper(); if (issueHelper.LoadDynamicFields(subscriber, news, null, null, false, siteName, null, null, null)) { body = issueHelper.ResolveDynamicFieldMacros(body, news); plainBody = issueHelper.ResolveDynamicFieldMacros(plainBody, news); } // Create e-mail var subscriberEmailRetriever = Service<ISubscriberEmailRetriever>.Entry(); var emailMessage = new EmailMessage { EmailFormat = EmailFormatEnum.Default, From = EmailHelper.GetSender(emailTemplate, news.NewsletterSenderEmail), Recipients = subscriberEmailRetriever.GetSubscriberEmail(subscriber.SubscriberID), BccRecipients = emailTemplate.TemplateBcc, CcRecipients = emailTemplate.TemplateCc, Subject = ResHelper.LocalizeString(emailTemplate.TemplateSubject), Body = URLHelper.MakeLinksAbsolute(body), PlainTextBody = URLHelper.MakeLinksAbsolute(plainBody) }; // Add attachments and send e-mail EmailHelper.ResolveMetaFileImages(emailMessage, emailTemplate.TemplateID, EmailTemplateInfo.OBJECT_TYPE, ObjectAttachmentsCategories.TEMPLATE); EmailSender.SendEmail(siteName, emailMessage); }
/// <summary> /// Creates and sends unsubscription e-mail. /// </summary> /// <param name="subscriber">Subscriber object</param> /// <param name="news">Newsletter object</param> /// <param name="subscription">Subscription object</param> /// <param name="siteName">Site name</param> protected void SendUnsubscriptionRequest(SubscriberInfo subscriber, NewsletterInfo news, SubscriberNewsletterInfo subscription, string siteName) { // Get global e-mail template with unsubscription request EmailTemplateInfo et = EmailTemplateProvider.GetEmailTemplate("newsletter.unsubscriptionrequest", siteName); if (et != null) { // Get subscriber member SortedDictionary<int, SubscriberInfo> subscribers = SubscriberInfoProvider.GetSubscribers(subscriber, 1, 0); foreach (KeyValuePair<int, SubscriberInfo> item in subscribers) { // Get 1st subscriber's member SubscriberInfo sb = item.Value; string body = et.TemplateText; string plainBody = et.TemplatePlainText; // Resolve newsletter macros (first name, last name etc.) IssueHelper ih = new IssueHelper(); if (ih.LoadDynamicFields(sb, news, subscription, null, false, siteName, null, null, null)) { body = ih.ResolveDynamicFieldMacros(body); plainBody = ih.ResolveDynamicFieldMacros(plainBody); } // Create e-mail EmailMessage msg = new EmailMessage(); msg.EmailFormat = EmailFormatEnum.Default; msg.From = EmailHelper.GetSender(et, news.NewsletterSenderEmail); msg.Recipients = sb.SubscriberEmail; msg.BccRecipients = et.TemplateBcc; msg.CcRecipients = et.TemplateCc; msg.Subject = ResHelper.LocalizeString(et.TemplateSubject); msg.Body = URLHelper.MakeLinksAbsolute(body); msg.PlainTextBody = URLHelper.MakeLinksAbsolute(plainBody); // Add attachments and send e-mail MetaFileInfoProvider.ResolveMetaFileImages(msg, et.TemplateID, EmailObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE); EmailSender.SendEmail(siteName, msg); } } else { // Log missing template EventLogProvider ev = new EventLogProvider(); ev.LogEvent(EventLogProvider.EVENT_TYPE_ERROR, DateTime.Now, "UnsubscriptionRequest", "Unsubscription request e-mail template is missing."); } }
protected void Page_Load(object sender, EventArgs e) { // Reset master page content CSS class CurrentMaster.PanelContent.CssClass = string.Empty; // Get edited issue object and check its existence IssueInfo issue = (IssueInfo)EditedObject; EditedObject = issue; // Get newsletter and check its existence newsletter = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if ((newsletter != null) && (newsletter.NewsletterType == NewsletterType.Dynamic)) { ShowError(GetString("Newsletter_Issue_Edit.CannotBeEdited")); editElem.StopProcessing = true; editElem.Visible = false; return; } // Get variant issue ID if A/B testing is ON int issueId = InitVariantSlider(issue.IssueID); // Initialize edit control editElem.IssueID = issueId; editElem.NewsletterID = issue.IssueNewsletterID; editElem.IsDialogMode = false; InitHeaderActions(issueId); }
/// <summary> /// Subscribes subscriber to the newsletter. /// </summary> /// <param name="subscriber">Subscriber object</param> /// <param name="newsletter">Newsletter which the subscriber will be subscribed to</param> /// <returns>True if subscription was successful.</returns> private bool SubscribeToNewsletter(SubscriberInfo subscriber, NewsletterInfo newsletter) { // Creates new Service for subscriptions var subscriptionService = Service<ISubscriptionService>.Entry(); try { subscriptionService.Subscribe(subscriber.SubscriberID, newsletter.NewsletterID, mSubscriptionSettings); return true; } catch (Exception exception) { Service<IEventLogService>.Entry().LogException("Newsletters", "Subscribe", exception); } return false; }
/// <summary> /// Sets newsletter object from config form data. /// </summary> /// <param name="newsletterObj">Newsletter object</param> private void SetNewsletterValues(NewsletterInfo newsletterObj) { newsletterObj.NewsletterDisplayName = txtNewsletterDisplayName.Text.Trim(); newsletterObj.NewsletterName = txtNewsletterName.Text.Trim(); newsletterObj.NewsletterSenderName = txtNewsletterSenderName.Text.Trim(); newsletterObj.NewsletterSenderEmail = txtNewsletterSenderEmail.Text.Trim(); newsletterObj.NewsletterBaseUrl = txtNewsletterBaseUrl.Text.Trim(); newsletterObj.NewsletterUnsubscribeUrl = txtNewsletterUnsubscribeUrl.Text.Trim(); newsletterObj.NewsletterDraftEmails = txtDraftEmails.Text; newsletterObj.NewsletterUseEmailQueue = chkUseEmailQueue.Checked; newsletterObj.NewsletterEnableResending = chkEnableResending.Checked; newsletterObj.NewsletterTrackOpenEmails = TrackingEnabled && chkTrackOpenedEmails.Checked; newsletterObj.NewsletterTrackClickedLinks = TrackingEnabled && chkTrackClickedLinks.Checked; newsletterObj.NewsletterLogActivity = OnlineMarketingEnabled && chkLogActivity.Checked; newsletterObj.NewsletterEnableOptIn = chkEnableOptIn.Checked && (ValidationHelper.GetInteger(optInSelector.Value, 0) > 0); newsletterObj.NewsletterOptInApprovalURL = txtOptInURL.Text.Trim(); newsletterObj.NewsletterSendOptInConfirmation = chkSendOptInConfirmation.Checked; }
/// <summary> /// Creates new scheduled task for the given issue and newsletter. /// </summary> /// <param name="issueId">Issue</param> /// <param name="newsletter">Newsletter</param> private int CreateScheduledTask(IssueInfo issue, NewsletterInfo newsletter) { if ((issue == null) || (newsletter == null)) { return 0; } // Create new scheduled task TaskInfo task = IssueInfoProvider.CreateMailoutTask(issue, newsletter, DateTime.Now, false); if (task != null) { TaskInfoProvider.SetTaskInfo(task); return task.TaskID; } return 0; }
private static void LogNewsletterSubscriptionActivity(SubscriberInfo subscriber, NewsletterInfo newsletter) { // Under what contacts this subscriber belogs to? int contactId = ActivityTrackingHelper.GetContactID(subscriber); if (contactId <= 0) { return; } // Activity object is created for contact taken from ActivityContext. // Set ID of contact opening this email into this context otherwise new contact could be created. var activityContext = AnalyticsContext.ActivityEnvironmentVariables; activityContext.ContactID = contactId; var activity = new ActivityNewsletterSubscribing(subscriber, newsletter, activityContext); activity.Log(); }
/// <summary> /// Creates dynamic newsletter. Called when the "Create newsletter" button is pressed. /// </summary> private bool CreateDynamicNewsletter() { EmailTemplateInfo subscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewSubscriptionTemplate", CMSContext.CurrentSiteID); EmailTemplateInfo unsubscriptionTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo("MyNewUnsubscriptionTemplate", CMSContext.CurrentSiteID); if ((subscriptionTemplate != null) && (unsubscriptionTemplate != null)) { // Create new dynamic newsletter object NewsletterInfo newNewsletter = new NewsletterInfo(); // Set the properties newNewsletter.NewsletterDisplayName = "My new dynamic newsletter"; newNewsletter.NewsletterName = "MyNewDynamicNewsletter"; newNewsletter.NewsletterType = NewsletterType.Dynamic; newNewsletter.NewsletterSubscriptionTemplateID = subscriptionTemplate.TemplateID; newNewsletter.NewsletterUnsubscriptionTemplateID = unsubscriptionTemplate.TemplateID; newNewsletter.NewsletterSenderName = "Sender name"; newNewsletter.NewsletterSenderEmail = "*****@*****.**"; newNewsletter.NewsletterDynamicURL = "http://www.google.com"; newNewsletter.NewsletterDynamicSubject = "My new dynamic issue"; newNewsletter.NewsletterSiteID = CMSContext.CurrentSiteID; // Save the dynamic newsletter NewsletterInfoProvider.SetNewsletterInfo(newNewsletter); return true; } return false; }
protected void Page_Load(object sender, EventArgs e) { // Get edited issue object and check its existence IssueInfo issue = EditedObject as IssueInfo; if (issue == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!issue.CheckPermissions(PermissionsEnum.Modify, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(issue.TypeInfo.ModuleName, "AuthorIssues"); } CurrentMaster.PanelContent.CssClass = "email-content"; // Get newsletter and check its existence newsletter = NewsletterInfoProvider.GetNewsletterInfo(issue.IssueNewsletterID); if ((newsletter != null) && (newsletter.NewsletterType == NewsletterType.Dynamic)) { ShowError(GetString("Newsletter_Issue_Edit.CannotBeEdited")); editElem.StopProcessing = true; editElem.Visible = false; return; } // Get variant issue ID if A/B testing is ON int issueId = InitVariantSlider(issue.IssueID); // Initialize edit control editElem.IssueID = issueId; editElem.NewsletterID = issue.IssueNewsletterID; InitHeaderActions(issueId); }
/// <summary> /// Performs action on given subscriber. /// </summary> /// <param name="newsletter">Newsletter info</param> /// <param name="actionName">Name of action</param> private void DoSubscriberAction(NewsletterInfo newsletter, string actionName) { try { var subscriber = SubscriberInfoProvider.GetSubscriberInfo(mSubscriberID); switch (actionName.ToUpperInvariant()) { case REMOVE: mSubscriptionService.RemoveSubscription(subscriber.SubscriberID, newsletter.NewsletterID, chkSendConfirmation.Checked); break; case APPROVE: SubscriberNewsletterInfoProvider.ApproveSubscription(mSubscriberID, newsletter.NewsletterID); break; } } // Exception might be thrown when one of the object does not exist, especially when newsletter gets deleted before refreshing this page. catch (Exception exception) { LogAndShowError("Subscriber subscriptions", "NEWSLETTERS", exception); } }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Check 'configure' permission if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.newsletter", "configure")) { RedirectToCMSDeskAccessDenied("cms.newsletter", "configure"); } // Validate base inputs (newsletter display name, code name, sender name, sender e-mail) string errorMessage = new Validator().NotEmpty(txtNewsletterDisplayName.Text.Trim(), GetString("general.requiresdisplayname")).NotEmpty(txtNewsletterName.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptyName")).NotEmpty(txtNewsletterSenderName.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptySenderName")).NotEmpty(txtNewsletterSenderEmail.Text.Trim(), GetString("Newsletter_Edit.ErrorEmptySenderEmail")).IsEmail(txtNewsletterSenderEmail.Text.Trim(), GetString("Newsletter_Edit.ErrorEmailFormat")).IsCodeName(txtNewsletterName.Text.Trim(), GetString("general.invalidcodename")).Result; if (String.IsNullOrEmpty(errorMessage)) { if (String.IsNullOrEmpty((string)subscriptionTemplate.Value)) { // No subscription template selected lblSubscriptionError.Visible = true; return; } if (String.IsNullOrEmpty((string)unsubscriptionTemplate.Value)) { // No unsubscription template selected lblUnsubscriptionError.Visible = true; return; } if ((radTemplateBased.Checked) && (String.IsNullOrEmpty((string)issueTemplate.Value))) { // No issue template selected for template based newsletter lblIssueError.Visible = true; return; } if ((radDynamic.Checked) && (chkSchedule.Checked) && (!ScheduleInterval.CheckOneDayMinimum())) { // Problem occurred while setting schedule interval for dynamic newsletter ShowError(GetString("Newsletter_Edit.NoDaySelected")); return; } if ((radDynamic.Checked) && (chkSchedule.Checked) && (SchedulingHelper.DecodeInterval(ScheduleInterval.ScheduleInterval).StartTime == DateTime.MinValue)) { ShowError(GetString("Newsletter.IncorrectDate")); return; } // Newsletter code name must to be unique per site... NewsletterInfo newsletterObj = NewsletterInfoProvider.GetNewsletterInfo(txtNewsletterName.Text.Trim(), CMSContext.CurrentSiteID); // If newsletter code name is unique... if (newsletterObj == null) { // Create new item -> insert newsletterObj = new NewsletterInfo(); newsletterObj.NewsletterDisplayName = txtNewsletterDisplayName.Text.Trim(); newsletterObj.NewsletterName = txtNewsletterName.Text.Trim(); int selectedValue = ValidationHelper.GetInteger(subscriptionTemplate.Value, 0); if (selectedValue != 0) { newsletterObj.NewsletterSubscriptionTemplateID = selectedValue; } else { ShowError(GetString("Newsletter_Edit.NoSubscriptionTemplateSelected")); return; } selectedValue = ValidationHelper.GetInteger(unsubscriptionTemplate.Value, 0); if (selectedValue != 0) { newsletterObj.NewsletterUnsubscriptionTemplateID = selectedValue; } else { ShowError(GetString("Newsletter_Edit.NoUnsubscriptionTemplateSelected")); return; } newsletterObj.NewsletterSenderName = txtNewsletterSenderName.Text.Trim(); newsletterObj.NewsletterSenderEmail = txtNewsletterSenderEmail.Text.Trim(); if (radDynamic.Checked) { newsletterObj.NewsletterDynamicURL = txtNewsletterDynamicURL.Text.Trim(); newsletterObj.NewsletterType = NewsletterType.Dynamic; } else { selectedValue = ValidationHelper.GetInteger(issueTemplate.Value, 0); if (selectedValue != 0) { newsletterObj.NewsletterTemplateID = selectedValue; } else { ShowError(GetString("Newsletter_Edit.NoEmailTemplateSelected")); return; } newsletterObj.NewsletterType = NewsletterType.TemplateBased; } newsletterObj.NewsletterSiteID = CMSContext.CurrentSiteID; newsletterObj.NewsletterGUID = Guid.NewGuid(); newsletterObj.NewsletterLogActivity = true; newsletterObj.NewsletterEnableResending = true; try { // Create new newsletter NewsletterInfoProvider.SetNewsletterInfo(newsletterObj); if (radDynamic.Checked) { if (chkSchedule.Checked) { // Create new task to schedule the dynamic newsletter TaskInfo task = new TaskInfo(); task.TaskAssemblyName = "CMS.Newsletter"; task.TaskClass = "CMS.Newsletter.DynamicNewsletterSender"; task.TaskDisplayName = GetString("DynamicNewsletter.TaskName") + newsletterObj.NewsletterDisplayName; task.TaskEnabled = true; task.TaskInterval = ScheduleInterval.ScheduleInterval; task.TaskLastResult = string.Empty; task.TaskName = "DynamicNewsletter." + ValidationHelper.GetCodeName(newsletterObj.NewsletterName, "_"); task.TaskSiteID = CMSContext.CurrentSiteID; task.TaskNextRunTime = SchedulingHelper.GetNextTime(task.TaskInterval, new DateTime(), new DateTime()); task.TaskData = newsletterObj.NewsletterGUID.ToString(); // Set task for processing in external service task.TaskAllowExternalService = true; task.TaskUseExternalService = (SchedulingHelper.UseExternalService && NewsletterHelper.UseExternalServiceForDynamicNewsletters(CMSContext.CurrentSiteName)); task.TaskType = ScheduledTaskTypeEnum.System; TaskInfoProvider.SetTaskInfo(task); newsletterObj.NewsletterDynamicScheduledTaskID = task.TaskID; NewsletterInfoProvider.SetNewsletterInfo(newsletterObj); } } URLHelper.Redirect("Newsletter_Frameset.aspx?newsletterid=" + ValidationHelper.GetString(newsletterObj.NewsletterID, null) + "&saved=1"); } catch (Exception ex) { ShowError(GetString(ex.Message)); } } else { ShowError(GetString("Newsletter_Edit.NewsletterNameExists")); } } else { ShowError(errorMessage); } }