More in this section

Forums / Developing with Sitefinity / How to add a "Subscribe to our newsletter" checkbox?

How to add a "Subscribe to our newsletter" checkbox?

2 posts, 0 answered
  1. Mark
    Mark avatar
    13 posts
    05 Aug 2010
    05 Aug 2010
    Link to this post

    What is the method used to allow a visitor to subscribe to a newsletter by selecting a checkbox on a contact form?  I have a simply contact form setup and I need to add a checkbox that allows users to subscribe to a checkbox.

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    01 Feb 2016
    10 Aug 2010
    Link to this post
    Hi Mark,

    If you are not using the Subscription form control which we distribute with Sitefinity you will have to use the Sitefinity API to create subscribers and assign them to newsletter. Bellow is a sample how you can add a subscriber to newsletter:
    Telerik.Notifications.Newsletters.DataManager dm = new Telerik.Notifications.Newsletters.DataManager();
    IGroup subsriberGroup = dm.GetGroup(groupId);
    string userEmail = "";
    ISubscriber subscriber = dm.CreateSubscriber(userEmail);
    subscriber.FirstName = "FirstName";
    subscriber.LastName = "LastName";
    IGroupSubscriber grSubs =    dm.CreateGroupSubscriberRelation(subscriberGroup.GroupId, subscriber.SubscriberId);

    the groupId variable is of type Guid and represents the ID of the subscriber group you want to assign the user to.

    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered