Exception if subscriber is already active


I am using sample for for c# to add new subscriber. Is there any way to raise exception if the subscriber is already active in a list?



Ken Ken, 3 years ago

Hi Rizwan,

Since I know you use our .NET Wrapper, before you add the subscriber, you will want to call the Get subscribers details method first (https://github.com/campaignmonitor/createsend-dotnet/blob/master/createsend-dotnet/Subscriber.cs#L16).

If the email address doesn't belong in the list, then you will get a 203 Subscriber not in list exception thrown, so you can proceed and add the email address. If you get a SubscriberDetail object back, you will want to check the State property. If it is Active, then you can throw your exception.

I hope that makes! Let me know if there is anything else I can do for you.

rhkiyani, 3 years ago

Thanks Ken for the answer in detail. It worked!

Here's what I ended up.

Subscriber subscriber = new Subscriber(auth, listid);

try {
  SubscriberDetail sub_detail = new SubscriberDetail();
  sub_detail = subscriber.Get("email");
  lbl_message.Text = sub_detail.State.ToString();
catch (CreatesendException ex) {
  ErrorResult error = (ErrorResult)ex.Data["ErrorResult"];
  if (error.Code == "203") {
catch (Exception ex) {
  //general exception


Ken Ken, 3 years ago

Awsome Rizwan! I'm glad you worked it out.


jamesfrank, 2 years ago

This looks like 70-646 email cloaking, and this may be being achieved through javascript. I would suspect this as the problem: perhaps try removing these <a>'s and see if you get further.

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free