Exception if subscriber is already active

Hi,

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?

Thanks,

Rizwan

Ken Ken, 2 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.


http://www.campaignmonitor.com
rhkiyani, 2 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") {
    subscriber.Add("email","name",null,false);
  }
}
catch (Exception ex) {
  //general exception
}


Regards,
Rizwan

Ken Ken, 2 years ago

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

Ken


http://www.campaignmonitor.com
jamesfrank, 1 year 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.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098