// 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 = "sender@localhost.local"; newNewsletter.NewsletterSiteID = CMSContext.CurrentSiteID;
// Save the static newsletter NewsletterProvider.SetNewsletter(newNewsletter);
returntrue; }
returnfalse; }
The following example gets and updates a static newsletter.
privatebool GetAndUpdateStaticNewsletter() { // Get the static newsletter Newsletter updateNewsletter = NewsletterProvider.GetNewsletter("MyNewStaticNewsletter", CMSContext.CurrentSiteID); if (updateNewsletter != null) { // Update the properties updateNewsletter.NewsletterDisplayName = updateNewsletter.NewsletterDisplayName.ToLower();
// Save the changes NewsletterProvider.SetNewsletter(updateNewsletter);
returntrue; }
returnfalse; }
The following example gets and bulk updates static newsletters.
privatebool GetAndBulkUpdateStaticNewsletters() { // Prepare the parameters string where = "NewsletterName LIKE N'MyNewStaticNewsletter%'";
// Get the data DataSet newsletters = NewsletterProvider.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 Newsletter modifyNewsletter = newNewsletter(newsletterDr);
// Update the properties modifyNewsletter.NewsletterDisplayName = modifyNewsletter.NewsletterDisplayName.ToUpper();
// Save the changes NewsletterProvider.SetNewsletter(modifyNewsletter); }
returntrue; }
returnfalse; }
The following example creates a dynamic newsletter.
if ((subscriptionTemplate != null) && (unsubscriptionTemplate != null))
{
// Create new dynamic newsletter object
Newsletter newNewsletter = newNewsletter();
// 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 = "sender@localhost.local"; newNewsletter.NewsletterDynamicURL = "http://www.google.com"; newNewsletter.NewsletterDynamicSubject = "My new dynamic issue"; newNewsletter.NewsletterSiteID = CMSContext.CurrentSiteID;
// Save the dynamic newsletter NewsletterProvider.SetNewsletter(newNewsletter);
returntrue; }
returnfalse; }
The following example gets and updates a dynamic newsletter.
privatebool GetAndUpdateDynamicNewsletter() { // Get the dynamic newsletter Newsletter updateNewsletter = NewsletterProvider.GetNewsletter("MyNewDynamicNewsletter", CMSContext.CurrentSiteID); if (updateNewsletter != null) { // Update the properties updateNewsletter.NewsletterDisplayName = updateNewsletter.NewsletterDisplayName.ToLower();
// Save the changes NewsletterProvider.SetNewsletter(updateNewsletter);
returntrue; }
returnfalse; }
The following example gets and bulk updates dynamic newsletters.
privatebool GetAndBulkUpdateDynamicNewsletters() { // Prepare the parameters string where = "NewsletterName LIKE N'MyNewDynamicNewsletter%'";
// Get the data DataSet newsletters = NewsletterProvider.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 Newsletter modifyNewsletter = newNewsletter(newsletterDr);
// Update the properties modifyNewsletter.NewsletterDisplayName = modifyNewsletter.NewsletterDisplayName.ToUpper();
// Save the changes NewsletterProvider.SetNewsletter(modifyNewsletter); }
returntrue; }
returnfalse; }
The following example deletes a dynamic newsletter.
privatebool DeleteDynamicNewsletter() { // Get the dynamic newsletter Newsletter deleteNewsletter = NewsletterProvider.GetNewsletter("MyNewDynamicNewsletter", CMSContext.CurrentSiteID);
// Delete the dynamic newsletter NewsletterProvider.DeleteNewsletter(deleteNewsletter);
return (deleteNewsletter != null);
}
The following example deletes a static newsletter.
privatebool DeleteStaticNewsletter() { // Get the static newsletter Newsletter deleteNewsletter = NewsletterProvider.GetNewsletter("MyNewStaticNewsletter", CMSContext.CurrentSiteID);
// Delete the static newsletter NewsletterProvider.DeleteNewsletter(deleteNewsletter);