We have a requirement where we need to expire the Subscription links generated by OE after a given time interval or after first use. I am thinking of adding two custom fields to the contacts_extended_details table - one to store the link generation date/time and the other one to indicate if the link has been used or not. On the presentation side I can create the contact object and check the values of these extended details and either let the user in or show a friendly message that the link has expired. The only thing I am not sure is how can set the values in these two fields when sending a mailing.

  • Hi and welcome to Tridion Stack Exchange. I'm a bit unclear on your exact question. It might help to rephrase it a little if you can please. – Rob Stevenson-Leggett May 18 '13 at 17:59
  • @RobStevenson-Leggett Sorry for not being clear in explaining my requirements. The basic requirement is to expire the subscription links either after a certain time interval from the generation of the links or after the first use. The only way I can think of doing this would be to add some custom extended_details to the contacts and set values at the time of sending the subscription links. But I am not sure how this can be implemented. – Husain Zahid May 19 '13 at 13:20

I don't think you can do much at the point the mailing is sent, maybe you could write a small script to run periodically on the CM side to check which Contacts got the mailing and update their extended details accordingly?

  • There is a chance of a delay between the mailing being sent and the script execution. How do we handle the case if someone receives the email and clicks on the link(s) before the script executes. – Husain Zahid May 22 '13 at 8:16

Yes you can easily set the value of this two field. After sending the email to user if it returns true, you can call below function which sets the values in database. Now on subscription page retrive the value from database on basis of email address( I am assuming that you will be having the email address of user on subscription page (may be from query string). Thanks

      public static bool ResetPassword(string email, int passwordResetKey, string passwordResetid)
                    Contact contact = GetContact(email);
                    if (contact != null)
// password reset id upadted in database
            contact.ExtendedDetails["PASSWORD_RESET_KEY"].Value = passwordResetKey;
// Guid sent as query string
            contact.ExtendedDetails["PASSWORD_RESET_ID"].Value = passwordResetid;
            if (passwordResetKey == 0)
// updated date in the database
            contact.ExtendedDetails["PASSWORD_RESET_DATE"].Value = Convert.ToDateTime(DateTime.Now.AddDays(2));
                            contact.ExtendedDetails["PASSWORD_RESET_DATE"].Value = null;
                catch (Exception ex)
                    //throw ex;
                    string msg = ex.Message.ToString();
                    return false;
                return true;

On CMS side:

        // 1. reterive all contacts
        var uri = new TcmUri(8, 2, TcmItemTypes.StaticAddressBook);
        var addressBook = new StaticAddressBook(uri);
        var filter = new ContactFilter(UserContext.Current);
        List<Contact> contactsList = new List<Contact>(Contact.GetContacts(filter, addressBook));
        var contacts = Contact.GetContacts(filter, addressBook);
        foreach (Contact unloadedContact in contactsList)
            // Re-load each Contact to access all of its data
                Contact contact = new Contact(unloadedContact.Id, UserContext.Current);

                // 2. send the email to contact
                 bool send = EmailManager.Send();
                //3. if send is true
                if (send)
                //update the field in the content manager database
                    contact.ExtendedDetails["Password_Reset_Value"].Value = 1;

  • Thank you for the reply. However note that some emails are not being triggered from the presentation side. Promotional emails (campaigns etc.) will be triggered from the CMS and those emails would also contain subscription links, which also have to be expired after a time interval or first use. – Husain Zahid May 22 '13 at 8:14
  • In the Promotional email code (CMS side) also you can set the value of these two extended fields. As the Sync servcie is running it will sync the two databases. – Meenakshi May 22 '13 at 11:35
  • Can you elaborate on how this can be achieved for the promotional emails? – Husain Zahid May 22 '13 at 12:21
  • I have updated the answer. 1. Retrieve all contacts from CMS side.(stackoverflow.com/questions/9687094/…) 2. Send Email to them 3. If send returns true update the field.(Although I have never updated the CMS field like this but should be). – Meenakshi May 22 '13 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.