More in this section
Forums / Developing with Sitefinity / Creating Group with Large Number of Subscribers via API

Creating Group with Large Number of Subscribers via API

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. Jon Kramme
    Jon Kramme avatar
    15 posts
    20 Dec 2009
    21 Jul 2010
    Link to this post
    I need to create a newsletter distribution group and add about 4,000 subscriber email addresses to it via the API from a web page.  My email addresses are coming from another database (non-Sitefinity).

    I wrote and tested the code locally, but it took about 10 to 15 minutes to process.  When I deploy it to the server, it dies at 3 minutes due to a timeout.  Even if I could increase the timeout limit, I don't like that approach because waiting 10 minutes for a web page to process is just way too long.

    Is there a way, via the API, to somehow have Sitefinity run a background thread that continues to process, but allows the web page to post back almost immediately?  What I have in mind is something like when you send a itefinity newsletter.  The newsletter admin page doesn't actually wait for each email to be sent, but displays a message that it's still running in the background with instructions on how to monitor the progress.

    My other idea is to code my page such that it only tries to do a fixed number of rows per page load, like 100, and uses a session variable to know when to stop trying to add more subscribers to the group.  I think it would work, but doesn't seem very graceful.


    Here is the code I have thus far...
    protected void btnNext_Click(object sender, EventArgs e)
        //create the group
        String groupName = DateTime.Today.Year.ToString() + " Membership Renewal";
        IGroup group = dataManager.CreateGroup();
        group.GroupName = groupName;
        //add subscribers
        MembersUpForRenewalTA ta = new MembersUpForRenewalTA();
        MembershipRenewalDataSet.MembersUpForRenewalDataTable membersUpForRenewal = ta.GetData();
        foreach (MembershipRenewalDataSet.MembersUpForRenewalRow memberUpForRenewal in membersUpForRenewal)
            AddSubscriberToGroup(group,, memberUpForRenewal.fname, memberUpForRenewal.lname);
        //Go to Sitefinity Newsletter admin screen
    private void AddSubscriberToGroup(IGroup Group, String Email, String FirstName, String LastName)
        //try to find the subscriber email
        ISubscriber subscriber = dataManager.GetSubscriber(Email);
        if (subscriber == null)
            //email doesn't exist, so create and save a new subscriber
            subscriber = dataManager.CreateSubscriber(Email);
            subscriber.FirstName = FirstName;
            subscriber.LastName = LastName;
        //see if the subscriber is already a member of the group
        IGroupSubscriber groupSubscriber = dataManager.GetGroupSubscriberRelation(Group.GroupId, subscriber.SubscriberId);
        if (groupSubscriber == null)
            //CONTINUE:  subscriber is not a member of the list, so create and save the relationship
            groupSubscriber = dataManager.CreateGroupSubscriberRelation(Group.GroupId, subscriber.SubscriberId);

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    21 Jul 2010
    Link to this post
    Hello Jon Kramme,

    We use Thread.Sleep Method - the thread is blocked and suspended to allow other waiting threads to execute. Newsletter messages are send between certain intervals, so you could specify some integer value in your code and pass it to Sleep method.

    All the best,
    Ivan Dimitrov
    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