示例#1
0
        public void SendUserActivationLinkMessage(User user, string activationUrl)
        {
            var message = LoadAndProcessTemplate(EmailTemplateNames.UserActivationLinkMessage, user);

            //additional tokens
            message.EmailBody = _tokenProcessor.ProcessProvidedTokens(message.EmailBody, new List <Token>
            {
                new Token(EmailTokenNames.ActivationUrl, activationUrl)
            });
            message.Tos.Add(new EmailMessage.UserInfo(user.Name, user.Email));
            _emailService.Queue(message);
        }
示例#2
0
        /// <summary>
        /// Gửi email đăng ký tài khoản tạo mật khẩu ngẫu nhiên
        /// </summary>
        /// <param name="user"></param>
        /// <param name="withAdmin"></param>
        /// <param name="randomPassword"></param>
        public void SendUserRegisteredMessage(User user, bool withAdmin, string randomPassword)
        {
            var message = LoadAndProcessTemplate(EmailTemplateNames.UserRegisteredRandomPassword, user);

            message.EmailBody = _tokenProcessor.ProcessProvidedTokens(message.EmailBody, new List <Token>
            {
                new Token(EmailTokenNames.RandomPassword, randomPassword)
            });
            message.To = user.Email;
            message.Tos.Add(new EmailMessage.UserInfo(user.FullName, user.Email));
            _emailService.Queue(message);
            if (withAdmin) //send to admin if needed
            {
                message = LoadAndProcessTemplate(EmailTemplateNames.UserRegisteredMessageToAdmin, user);

                if (message != null)
                {
                    message.To = message.OriginalEmailTemplate.AdministrationEmail;
                    message.Tos.Add(new EmailMessage.UserInfo("Administrator", message.OriginalEmailTemplate.AdministrationEmail));
                    _emailService.Queue(message);
                }
            }
        }