More in this section
Categories
Bloggers
Blogs RSS feed

How to Display Email Campaign Issues on Sitefinity Pages

by User Not Found
In this blog post I'm going to show you how to place links to already sent Email campaign issues on your Sitefinity pages. The same approach can be used to link fallback versions of your campaigns, directly in the issue itself.

To achieve this, we need two simple user controls:

  • NewsLettersFront contains a repeater that lists all your issues. Since all Sitefinity newsletters campaigns have internal links, that aren't visible if you're not logged it, you don't have a link for each issue as there used to be in 5.1. This functionality is removed, because of security reasons. What we'll do is render the content of the issue on a Sitefinity page, which will simulate the issue being opened in the browser. The repeater lists anchor items with URLs, leading to some page, concatenated with a queryString, where we pass the id of the issue. As I mentioned, you pass the issue id in the queryString and you're redirected to some page. Then on this page you have the CampaignDetail widget.
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="NewsLettersFront.ascx.cs" Inherits="SitefinityWebApp.NewsLettersFront" %>
 
<asp:Repeater runat="server" ID="myRep">
    <HeaderTemplate>
        <div class="span11">
            <div class="quotestests">
    </HeaderTemplate>
    <ItemTemplate>
           <a href='<%# string.Format("nameOfPageForIssues?id={0}", Eval("Id")) %>' ><%#Eval("Name")%></a>
        <br />
    </ItemTemplate>
    <FooterTemplate>
            </div>
        </div>
    </FooterTemplate>
 
</asp:Repeater>

code-behind
namespace SitefinityWebApp
{
    public partial class NewsLettersFront : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var pManager = PageManager.GetManager();
            using (ElevatedModeRegion elevatedModeRegion = new ElevatedModeRegion(pManager))
            {
 
                NewslettersManager manager = NewslettersManager.GetManager();
                Campaign campaign = manager.GetCampaigns().Where(c => c.Name == "TestCampaign").SingleOrDefault();
                var issues = manager.GetIssues(campaign);
                var render = new InMemoryPageRender();
 
 
                myRep.DataSource = issues;
                myRep.DataBind();
 
            }
 
        }
 
    }
}


  • CampaignDetail handles the logic for getting the queryString parameter value and using it to retrieve the issue. I'm retrieving the issue by its id with the GetIssue() method of the NewslettersManager. After you have the issue, you get its html, and with ResponseWrite (passing the html) you recreate the issue on the page. This way it looks like you're opening the issue in a new page:
public partial class CampaignDetail : System.Web.UI.UserControl
   {
       protected void Page_Load(object sender, EventArgs e)
       {
           var pManager = PageManager.GetManager();
           NewslettersManager newsletterManager = NewslettersManager.GetManager();
           var render = new InMemoryPageRender();
           var queryStringId = Request.QueryString["id"];
           if (queryStringId != null)
           {
               Campaign issue = newsletterManager.GetIssue(new Guid(queryStringId));
               if (issue != null)
               {
 
                   var campaignMessageBody = issue.MessageBody;
                   var node = pManager.GetPageNode(campaignMessageBody.Id);
                   var text = render.RenderPage(node, false, isIndexMode: false);
                   var realHtml = HtmlProcessor.ProcessHtml(text);
 
                   Response.Write(realHtml);
                   Response.Write("<br/>");
               }
           }
 
       }
   }

As mentioned above, you can use this approach to place fallback campaign links directly on the emails, sent to your subscribers.

Hope you find the blog post useful!

28 comments

Leave a comment
  1. Jen Apr 22, 2013
    Amanda, please make sure that the issue you got is not empty, since this is the markup, which would be rendered by an empty email campaign issue.
  2. Amanda S. Apr 22, 2013
    Hi Jen
    When I check var campaingMessageBodyText = issue.MessageBody.BodyText; I'm able to see the content, so I'm fairly certain it's not blank.
    Maybe I should send in a support ticket for you guys to look at it?

    I think this is a great added functionality. One of the complaints I had head was that there was no 'archive' of the newsletter editions. So this will greatly help us.
  3. Jen Apr 23, 2013
    Hello Amanda!

    I'm glad that you found the blog post useful. As you mentioned already, opening a support ticket, will allow us to investigate this behavior further.
  4. Gawein May 09, 2013
    Hi,

    I am experiencing the same output as Amanda. I also get an empty div. But if I request issue.MessageBody.BodyText I do get the correct html code!
    What does render.RenderPage and HtmlProcessor.ProcessHtml do?
  5. Joshua Mar 22, 2014
    Thank you for sharing this! Just what I’ve been searching for. Great info!
  6. Andrew Mar 22, 2014

    Nice.

  7. Marien Brethouwer Oct 29, 2014

    Hi, Great Post!

    You mention that you could use these online versions as a fallback from within the issue itself. I would like to know how to generate the url in the issue that is being send to the subscribers that links to the specific online version of the issue, could you please tell me how you did this? 

    Many thanks in advance.

  8. kelly Apr 11, 2018
    We know well to nba live mobile cheats online when you want the coins here to generate the hacks.
  9. Jarry120 Apr 20, 2018
    This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck! 
    Hewlett Packard Support Number
  10. Nitish May 08, 2018
    This content is wonderful, informative. It can collect all the information and it has really great effect on the new technology which is found now a days.Thanks for sharing it. Techavera providing the best AWS Sysops Training Course in Noida Visit us For Quality Learning.
  11. Jarry120 May 08, 2018
    This is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck! 
    HP Printer Help Number UK
  12. Article May 17, 2018
    Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share.Article
  13. Gold Storage Dubai May 17, 2018
    Great survey, I'm sure you're getting a great response.Gold Storage Dubai
  14. generator australia May 17, 2018
    Great post, and great website. Thanks for the information!generator australia
  15. kerja dari rumah May 17, 2018
    Thank you very much for this great post.kerja dari rumah
  16. bercuti May 17, 2018
    Exactly, you're very kind of us about comment!.bercuti
  17. Mona123 May 17, 2018
    I am happy to be here and this wonderful article. I have found here lots of interesting information for my knowledge I need. all the details you provide to us, it was very helpful and useful, thanks for sharing this amazing post.
    Norton Customer Service UK
  18. restaurantes polanco May 17, 2018
    This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information...restaurantes polanco
  19. cours de cuisine paris May 17, 2018
    Thanks for this article very helpful. thanks.cours de cuisine paris
  20. Orlando Wedding May 17, 2018
    Your music is amazing. You have some very talented artists. I wish you the best of success.Orlando Wedding
  21. roseville chiropractors May 17, 2018
    Great post I would like to thank you for the efforts you have made in writing this interesting and knowledgeable article.roseville chiropractors
  22. CV Writers Brisbane May 17, 2018
    Thank you for taking the time to publish this information very useful!CV Writers Brisbane
  23. wandolec May 17, 2018
    Thank you for taking the time to publish this information very useful!wandolec
  24. james Bond island May 17, 2018
    Superbly written article, if only all bloggers offered the same content as you, the internet would be a far better place..James Bond island
  25. painting company Wrentham MA May 17, 2018
    I really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day!painting company Wrentham MA
  26. Florida Business Telecommunications May 17, 2018
    This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free.Florida Business Telecommunications
  27. DETECTIVES EN MADRID May 18, 2018
    This is a great post. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again.DETECTIVES EN MADRID
  28. mens incontinence pants May 21, 2018
    Fantastic blog! Do you have any tips and hints for aspiring writers? I’m planning to start my own website soon but I’m a little lost on everything. Would you propose starting with a free platform like WordPress or go for a paid option? There are so many options out there that I’m completely overwhelmed .. Any suggestions? Many thanks!mens incontinence pants

    Leave a comment