Creating a mailing list

To create a mailing list, you use the NewslettersManager class. The following code creates a mailing list with the specified IdTitle,DefaultFromNameDefaultReplyToEmail and DefaultSubject through the Native API.

public void CreateMailingList(Guid id, string title, string fromName, string replyToEmail, string subject)
{
    NewslettersManager manager = NewslettersManager.GetManager();
    MailingList mailingList = manager.GetMailingLists().Where(l => l.Id == id).SingleOrDefault();
 
    if (mailingList == null)
    {
        mailingList = manager.CreateList(id);
        mailingList.Title = title;
        mailingList.DefaultFromName = fromName;
        mailingList.DefaultReplyToEmail = replyToEmail;
        mailingList.DefaultSubject = subject;
        manager.SaveChanges();
    }
}

First, you initialize the NewslettersManager. Then, you call GetMailingLists to get all mailing lists. Then, you check whether an item with the specified ID exists. Finally, you call the CreateList method, set all properties, and save the changes.

Next steps

+1-888-365-2779
sales@sitefinity.com

Related topics:

Feedback

How useful is this article?

Tell us more

Submit
Your message was successfully sent.

We appreciate your feedback.

Your message could not be sent.

OK