Handle specific newsletter subscriptions

Tracey Penberthy asked on March 14, 2017 13:58

Hi

I would like to listen out for when someone subscribes to a particular newsletter so that I can perform some extra functions.

I have a global event handler module that listens for SubscriberNewsletterInfo insert events

protected override void OnInit()
{
    base.OnInit();
    SubscriberNewsletterInfo.TYPEINFO.Events.Insert.Before += Newsletter_Insert_Before;
}
private void Newsletter_Insert_Before(object sender, ObjectEventArgs e)
{           
    EventLogProvider.LogInformation("LogChangeHandlerModule", "Newsletter_Insert_Before", "A newsletter is being subscribed to");
}

I have no idea how to check which newsletter is being subscribed to (or indeed if this is the best way to go about this).

Any help would be very gratefully received.

Correct Answer

Suneel Jhangiani answered on March 14, 2017 15:14

The SubscriberNewsletterInfo object should be in the ObjectEventerArgs:

private void Newsletter_Insert_Before(object sender, ObjectEventArgs e)
{           
    SubscriberNewsletterInfo sni = (SubscriberNewsletterInfo)e.Object;
    EventLogProvider.LogInformation("LogChangeHandlerModule", "Newsletter_Insert_Before", $"New Subscription to Newsletter ID:{sni.NewsletterID}" );
}
1 votesVote for this answer Unmark Correct answer

Recent Answers


Tracey Penberthy answered on March 14, 2017 15:17

Thanks Suneel

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.