When used on a Content Studio document it provides visitors with a list of their current newsletter subscriptions and offers the possibility to remove them (unsubscribe). This control only handles subscribers stored in the built in subscriber repository.

Background

The document author must provide a way of collection the visitor's email address that must be set before this control works. The address can be stored in a cookie after that the subscriber has logged in and set to the control in the Page_Load event. The control also offers the possibility to validate the action through a conformation mail or the selected subscriptions can be removed directly.

Using confirmation messages

The control has a built in support for mail base confirmation of removals. It works by sending a specially crafted mail to the subscriber. Content Studio cannot send out mail until the mail settings have been configured in Web.config. This includes the name of the Mail server to use and the optional authentication credentials and method to use. Remember, not all mail server are configured to allow anonymous sending of mail messages.

The following code example specifies the appropriate SMTP parameters to send e-mail using the default network credentials using an SMTP server named POSTMAN.

<configuration>

  <!--Other setting elements might exist -->
  
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="network">
        <network
          host="POSTMAN"
          port="25"
          defaultCredentials="true"
        />
      </smtp>
    </mailSettings>
  </system.net>
  
  <!--Other configuration elements might exist -->
  
</configuration>
                    

Examples

When placed on a Content Studio document the SubscriptionRemover control can look something like this

Remove your subscriptions
Select the subscriptions you would like to remove and press the 'Remove now!' button. The removal must be confirmed via a mail message sent to your address.

The control above is rendered by using the following source code in the Html designer

HTML
<csx:SubscriptionRemover RunAt="Server"
                         Id="SubscriptionRemover1"
                         CssClass="control" 
                         SuccessText="The subscription was removed!"
                         ConfirmationMailSenderAddress="info@corp.com" 
                         ConfirmationMessageDocument="/news/newsUtils/confirmRemoveMailMessage.aspx"
                         RequiresConfirmation="True" 
                         DefaultNoSubscriptionText="You currently have no subscriptions."
                         NothingSelectedText="Please, select at least one subscription!"
                         CommentText="Select the subscriptions you would like to remove and press the 'Remove now!' button. The removal must be confirmed via a mail message sent to your address."
                         CommentCssClass="smallface"
                         IncludeDisabled="True"
                         Text="Remove your subscriptions"
                         SuccessUrl="/news/newsUtils/afterRemoveSuccess.aspx"
                         Text="Remove your subscriptions"
                         ButtonText="Remove now!" /> 

In the page's Load event you must include code that tells the control the identity (in the Identifier property) of the subscriber whose subscriptions should be loaded. This identity is typically the email address of the user so that information have to be collected in some way. This can be the user data stored in the email field of the caller user data. That information, provided that it exists can easily be obtained using the UserProperties class. However, this only works if the user has a windows login and the email property has been set. By using forms login you can tuck away the email address in the user repository and obtain it after a successful login. The sample below is very simple - the subscriber's address is just hard coded, which is, of course, a very bad idea!

C#
// This will run on page load
protected void Page_Load(object sender, EventArgs e )
{
	// Enter code here...
	
	SubscriptionRemover1.Identifier = "john.doe@corp.com";
} 
    

See also

SubscriptionRemover Control API reference
SubscriptionManager Control