Unsubscribe from all campaigns
The unsubscribe widget will selectively remove the subscriber from the mailing list used by the campaign. How can we create an unsubscribe widget that will remove the user from ALL mailing lists in the system?
Hi Corbett,
I'm using the code below for that purpose. Perhaps it helps.
Dim
NewslettersManager
As
Telerik.Sitefinity.Modules.Newsletters.NewslettersManager = Telerik.Sitefinity.Modules.Newsletters.NewslettersManager.GetManager()
' Check if this user exists as a subscriber, regardless of the mailing lists(s) it is subscribed to.
Dim
Subscriber
As
Telerik.Sitefinity.Newsletters.Model.Subscriber = NewslettersManager.Provider.GetSubscribers().Where(
Function
(s) s.Email = EmailAddress).SingleOrDefault()
If
(Subscriber IsNot
Nothing
)
Then
' Remove the user as a subscriber all together.
NewslettersManager.DeleteSubscriber(Subscriber.Id)
NewslettersManager.SaveChanges()
End
If