Yes, it is possible to read the campaigns, issues and templates by code.
If I understand you correctly, your users create message templates, and you wish to create sendable campaigns based on those templates.
Please refer to the following code smaple:
NewslettersManager nlMgr = NewslettersManager.GetManager();
var template = nlMgr.GetMessageBodies()
.FirstOrDefault(b => b.Name ==
var list = nlMgr.GetMailingLists()
.FirstOrDefault(l => l.Title ==
"My mailing list"
var newCampaign = nlMgr.CreateCampaign(
"Based on a template!"
"Sitefinity campaigns demo"
newCampaign.List = list;
newCampaign.MessageBody.BodyText = template.BodyText;
newCampaign.MessageBody.CopiedTemplateId = template.Id;
newCampaign.MessageBody.MessageBodyType = template.MessageBodyType;
newCampaign.MessageBody.PlainTextVersion = template.PlainTextVersion;
var issue = nlMgr.CreateIssue(newCampaign,
- First this code uses NewslettersManager to retrieve a message template, specifically by its name ("My template").
- It also retrieves a specific mailing list which contains defaults for the message delivery and a collection of subscribers to which the campaign can be sent.
- Next a campaign is created.
Note that the campaign's MessageBody members are populated by values coped from the template.
- Also note that the FromName property of the campaign is populated. This is to address your 2nd bullet about specifying the sender's name.
- The campaign is saved.
- An issue based on the campaign which was just created is being created and saved.
At this point all the values from the campaign are copied automatically to the issue.
- The issue is now ready to be sent. It's possible to also send it directly by code, as demonstrated here.
This code should work fine as long as the template's bodies are plain text or rich text based. If a template is "like a web page" there are additional steps to be taken in order to copy the template's content to the created campaign and/or issue.
Please contact us for more information about web page templates or any additional help about this matter.
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking
system and vote to affect the priority of the items