danesparza / MailChimp.NET

:envelope: .NET Wrapper for the MailChimp v2.0 API
MIT License
179 stars 119 forks source link

AddStaticSegmentMembers with more than 20K emails results in timeout #208

Open danceoften opened 7 years ago

danceoften commented 7 years ago

Thanx for this super component, I have a problem when creating CampaignSegmentOptions when adding the segment: how can I increase the timeout? Could I simply AddStaticSegmentMembers multiple times in chunks to the same segment before creating the CreateCampaign?

Here's my code:

`IEnumerable emails ; //... code to get 25K emails from DB

CampaignSegmentOptions campaignSegmentOptions = null; // default tutti senza segmento

        if (emails != null && emails.Count > 0)
        {
            campaignSegmentOptions = new CampaignSegmentOptions();
            var seg = manager.AddStaticSegment(list, string.Format("{0}-{1}-{2}-{3}", "static", list, title, DateTime.Now.ToString("s")));
            manager.AddStaticSegmentMembers(list, seg.NewStaticSegmentID, new List<EmailParameter>(emails.Select(e => new EmailParameter
            {
                Email = e
            })));

// ------------EXCEPTION HAPPENS HERE campaignSegmentOptions.SavedSegmentId = seg.NewStaticSegmentID.ToString(); }

        var camp = manager.CreateCampaign("regular", new CampaignCreateOptions
        {
            FromEmail = mailFrom ?? fromEmail,
            FromName = nameFrom ?? fromName,
            ListId = list,
            Subject = subject,
            Title = title,
            GenerateText = true
        }, new CampaignCreateContent
        {
            HTML = completeHtml
        }, campaignSegmentOptions);

//........................`

thanx for you support

danesparza commented 7 years ago

I'm glad you've gotten good use out of this component!

FYI: This project is not longer actively maintained. However, it uses ServiceStack under the covers to make an API call here: https://github.com/danesparza/MailChimp.NET/blob/master/MailChimp/MailChimpManager.cs#L3294 so you may want to investigate how to configure servicestack to have an increased timeout.

Other devs who have used the component may be able to add additional information, so I'll leave this question here for others to answer.