Format for how to define rules for a segment (createsend_dotnet)

I am able to successfully create a list and add subscribers with the createsend_dotnet wrapper.  I am stuck on how to format the rules when creating a segment for a list.

I see the function that I need to use, but I don't know how to format the Segment Rules part

Segment.Create (List ID, "Segment Title", Segment Rules);

If I have a custom field called region and I want to create a segment for subscribers in the north region how do I finish the function

Segment.Create (myListID, "North Segment", ????);
Ken Ken, 4 years ago

Hi,

You'll need to create and populate a SegmentRules object. See in createsend-dotnet\Models\Segment.cs.

Here's an example:

var rules = new SegmentRules()
            {
                new Rule() {
                    Subject = "EmailAddress",
                    Clauses = new List<string>() {
                        "CONTAINS @domain.com"
                    }
                },
                new Rule() {
                    Subject = "DateSubscribed",
                    Clauses = new List<string>() {
                        "AFTER 2009-01-01",
                        "BEFORE 2010-01-01"
                    }
                }
            };

Let me know if you have any problem with it.


http://www.campaignmonitor.com
rjgonzalez73, 4 years ago

Ken,

Thanks for the code. This is exactly what I needed.

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free
1-888-533-8098