In your solution you'll have to create a new usercontrol, which will be our base for the subscribe macro.
  • Add a reference to the Designit.Umb.Newsletter.Bll.dll (located in your umbraco bin folder)
  • Depending on how you would like your unsubscribe page to work, create the UI and code behind. The code below is just examples on how the codebehind could look like.

There are more than one way to unsubscribe. It all depends on how you would like it to be. You can either unsubscribe a user from all groups or just specific groups.
If you want any UI on this page is again up to you. It could be, that you would like to show all groups, that the member is a part of, so the member can select which groups to unsubscribe from.
First thing is to retrieve the members e-mail address - either with a textbox, where the member inputs the e-mail or if you've used the unsubscribe tag in a newsletter and the user clicked the unsubscribe link.

//unsubscribe from all groups
var email = Request["mail"]
Member member = Member.GetMemberFromEmail(email);
Designit.Umb.Newsletter.Bll.Unsubscribe.UnsubscribeAll(member);

//Unsubscribe to certain groups
var email = Request["mail"]
var group = MemberGroup.GetByName(Request["groupName"]);
Member member = Member.GetMemberFromEmail(email);
Designit.Umb.Newsletter.Bll.Unsubscribe.UnsubscribeToGroup(member, group);
  • Now build the solution, copy the dll file to your umbraco bin folder and the ascx file to your umbraco usercontrols folder
  • Create a macro using the usercontrol
  • Add the macro to a page/template of your choice
  • Now go to the Newsletter section -> mail settings and fill in the Unsubscribe page field with the url of the new unsubscribe page - eg. http://yourdomain.com/unsubscribe.aspx

Last edited Apr 7, 2010 at 10:57 AM by raly76, version 3

Comments

No comments yet.