protected string CreateBody(PageAccessToken token, string pageName)
        {
            var sb = new StringBuilder();

            sb.AppendLine();
            sb.AppendFormat(Translate("/tokenbasedaccess/emailbodyformat"), pageName, SiteDisplayName);
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine(token.TokenUrl);
            sb.AppendLine();
            sb.Append(Translate("/tokenbasedaccess/emailbodyaccess"));
            sb.AppendLine(TokenExpiresInText(token));

            return sb.ToString();
        }
        protected string TokenExpiresInText(PageAccessToken token)
        {
            if (token.HasExpired)
                return Translate("/tokenbasedaccess/expired");

            if (token.ExpirationType == TokenExpirationType.AbsoluteExpiry)
            {
                var remaining = token.Created.Add(token.ValidityLimit);
                return string.Format("{0} {1}", Translate("/tokenbasedaccess/expireson"), remaining.ToLongDateString());
            }

            var remainingUses = token.UsageLimit - token.UsageCount;
            return remainingUses > 1
                       ? string.Format("{0} {1} {2}", Translate("/tokenbasedaccess/expiresin"),
                                       remainingUses, Translate("/tokenbasedaccess/uses"))
                       : string.Format("{0} {1} {2}", Translate("/tokenbasedaccess/expiresin"),
                                       remainingUses, Translate("/tokenbasedaccess/use"));
        }
        private void SendNotification(PageAccessToken token)
        {
            var pageReference = new PageReference(token.PageId, token.WorkId);
            string pageName = DataFactory.Instance.GetPage(pageReference).PageName;
            string subject = CreateSubject(pageName);
            string body = CreateBody(token, pageName);

            _notifications.Send(token.SentTo, subject, body);
        }