Sitefinity ASP.NET CMS

Not answered auto generated newsletter

Feed from this thread
  • TLsf avatar

    Posted on Sep 30, 2008 (permalink)

    Hello,

    We are trying to come up with a way to auto-generate a newsletter with information from the News and Events modules. Ideally we would be able to specify which categories of News and Events to return, and the fields: Title, Summary, Content, Date... and get formatted HTML code in return which we can paste in the Newsletter module.

    Does anyone have already finished code that extracts News and Events or has done something similar that can get us started? Any help will be much appreciated.

    Reply

  • SelArom MVP SelArom's avatar

    Posted on Sep 30, 2008 (permalink)

    this is pretty straightforward with the content APIs. I don't have a completed example you could borrow but I did something similar to build an rss feed of a custom module...

    basically you just need to use the api to get a collection of events/news/etc then iterate through each one and build the html.

    an example of the api is here: http://www.sitefinity.com/help/developer-manual/news-api-walkthrough.html which covers the news. here's a relevant snippet:

    // create new instance of NewsManager  
    Telerik.News.NewsManager newsManager = new Telerik.News.NewsManager("News");  
    // get all news content items  
    IList listOfNewsItems = newsManager.Content.GetContent();  
    if (listOfNewsItems.Count > 0)  
    {  
     foreach(Telerik.Cms.Engine.IContent newsItem in listOfNewsItems)  
         Response.Write(newsItem.GetMetaData("Title") + "<br />");  

    your code would go in place of that last line to build the html using the various MetaData items for the News item.

    here's the link for events: http://www.sitefinity.com/help/developer-manual/events-api-finding-events.html

    you can wrap these into a GetNewsletter method that returns the built html.

    hope that this was helpful!

    Reply

  • Telerik Admin admin's avatar

    Posted on Sep 30, 2008 (permalink)

    Hello,
    Josh beat me to the punch. Here's how to get the content items from given category though:
            IList listOfNewsItems = newsManager.Content.GetContent("[CategoryName] ASC");  
            if (listOfNewsItems.Count > 0)  
            {  
                foreach (Telerik.Cms.Engine.IContent newsItem in listOfNewsItems)  
                {  
                    NetmediaPanel1.Text += newsItem.GetMetaData("Title") + "<br />";  
                    //news1.Text += newsItem.GetMetaData("Category") + "<br />";  
                    NetmediaPanel1.Text += newsItem.Content.ToString() + "<br /><br />";  
                }  
            }  

    Josh, we have updated your Telerik account for a helpful reply. Thanks!

    Best wishes,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

    Reply

  • TLsf avatar

    Posted on Oct 1, 2008 (permalink)

    Thank you to both of you. This was really helpful. I'll give it a go.

    Reply

About Telerik

Telerik, the publisher of Sitefinity CMS, is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting and .NET ORMTFSCode Analysis and Web Application Testing tools. Building on its solid expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Created with passion, Telerik products help thousands of developers every day to be more productive and deliver reliable applications under budget and on time. Read more about Telerik

Copyright © 2002-2010 Telerik. All rights reserved. Powered by Sitefinity