You could keep your newsletters as content in the content sextionde - otherwise you would have to list sent letters from the Newsletter repository and render them from there.
I'm well aware of that we need a better API for this, I would not recommend going to the db directlly - this would be my recommended solution at the moment (Works on Newsletter Studio 2+):
@using NewsletterStudio.Core.Model
@using NewsletterStudio.Infrastucture
@using NewsletterStudio.Infrastucture.Services
@using NewsletterStudio.Services.RenderTasks
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
}
@{
// This will give you all the newsletters thats listed in the "Sent"-folder in the backoffice. This means that they are not older than 90 days.
var listOfNewslettersLast90Days = new NewsletterService(GlobalFactory.Current.NewsletterRepository).GetSent();
// This will give you all letters that has been successfully sent.
var listOfAllSentNewsletters = NewsletterStudio.Infrastucture.GlobalFactory.Current.NewsletterRepository.GetByStatus(new int[] { NewsletterStatus.Completed});
}
@if (Request.QueryString["id"] == null)
{
<ul>
@foreach (var item in listOfAllSentNewsletters)
{
<p>
<a href="/[email protected]">@item.Name</a>
</p>
}
</ul>
}
else
{
var letter = GlobalFactory.Current.NewsletterRepository.GetById(Convert.ToInt32(Request.QueryString["id"]));
RenderEngine renderEngine = new RenderEngine(letter);
@Html.Raw(renderEngine.RenderPreview())
}
List sent newsletters on frontend
Hi,
It may have been asked before, but is it possible to make a list of the sent newsletters on the frontend?
I'm aware, that there are some merge-fields and personalization, which cannot be rendered properly.
Kind regards Kurt
Hi!
You could keep your newsletters as content in the content sextionde - otherwise you would have to list sent letters from the Newsletter repository and render them from there.
/ m
Hi,
At the moment we are not using it as content in the content section, but in the Newsletter Studio alone.
Would you suggest, that we make a query directly in the database and list them from here?
Kind regards Kurt
Hi!
I'm well aware of that we need a better API for this, I would not recommend going to the db directlly - this would be my recommended solution at the moment (Works on Newsletter Studio 2+):
You can also find it here:
https://gist.github.com/enkelmedia/f91ba5c9cad0fa2b67be5de07b83763c
Thank you very much for your feedback.
Our customer is using version 1.4.5.1, but is it also usable with this version?
Hi!
Yes I think everything will work except this since the NewsletterService was added in V2.
var listOfNewslettersLast90Days = new NewsletterService(GlobalFactory.Current.NewsletterRepository).GetSent();
Give it a try and see what happens?
Hi,
Thank you for your response. I will give it a go :)
is working on a reply...