More in this section

Forums / Developing with Sitefinity / Double Opt-In Newsletter

Double Opt-In Newsletter

2 posts, 1 answered
  1. Tobi
    Tobi avatar
    3 posts
    Registered:
    17 Sep 2009
    25 Sep 2009
    Link to this post
    Hi,

    Sitefinity is a very cool tool, but now we can't find a simple solution.

    Our client needs a confirmed opt-in newsletter registration.
    After a user subscribes to the newsletter on the homepage, he receives an e-mail, that he has to confirm by clicking on a link.
    In Germany it's the standard manner to subscribe a seriously newsletter.

    Does such a solution in Sitefinity exist?

    If not, how can we solve this problem simply? 

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    25 Sep 2009
    Link to this post
    Hi Tobi,

    It is achievable task but it is a quite complicated.

    1. You need to create  User Interface in the backend of Sitefinity. In this interface you can implement button that will do the actual approval. In a table or RadGrid you can list all subscribers so that you will be able to see who has confirm your request.
    You need to create a new database table. This table should contains the following columns - email address, Unique Key - you should generate unique key for each user so that this key will be sent as a query string appended to a url, DateTime column - here you will store the date when user has requested subscription. Afterward you will use this date for implementing expiration.
    To send an email you can use  SmtpClient and MailMessage  classes. In the body of your email you need to add the server path and a url to a page you have already created. To this page you should append the Unique Key.

     
     
    string body = "please click the link below:\r\n\r\n" +  
     
            pathToApp + "Email.aspx?email=" +  
     
            server.UrlEncode(email) + "&UniquID=" +  
     
            Convert.ToString(UniqueKey) +  
     
            "\r\n\r\nThanks.";  
     
      
     


    Once a user receives this email he/she has to click on the link. Then this user will be sent to your Email.aspx( validation) page. On this page you should have a custom control that check whether the UniqueKey supplied in the QueryString is the same as this one written to the database. If so we are checking the expiration data of the link. You need to get the DateTime value from the database and check whether it is less that say 2 days.

    DateTime time = new DateTime();  
     
    time.AddDays(2);  
     


    To compare the DateTime you can use DateTime.Compare method.

    int compareTime = DateTime.Compare(DateTime.Now, email.SubscriptionDate);  
    //DateTime.Now is less than email.SubscriptionDate  
     
    if( compareTime < 0 )  
    {  
       //Do some process  
    }  
     


    After the user confirm subscription you should update the some value in the database table. For instance you could have another column which value returns true or false - approved or not approved user.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
2 posts, 1 answered