Ejemplo n.º 1
0
 public ActionResult ResendEmail(ResendEmailModel model)
 {
     if (ModelState.IsValid)
     {
         var response = _emailLogService.ResendEmail(model);
         SetResponseMessage(response);
         if (response.Success)
         {
             return(View("CloseFancyBox",
                         new CloseFancyBoxViewModel
             {
                 IsReload = true
             }));
         }
     }
     model.EmailAccounts = _emailAccountService.GetEmailAccounts();
     return(View(model));
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Resend the email
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResponseModel ResendEmail(ResendEmailModel model)
        {
            var emailLog = GetById(model.EmailLogId);

            if (emailLog == null)
            {
                return new ResponseModel
                       {
                           Success = false,
                           Message = T("EmailLog_Message_ObjectNotFound")
                       }
            }
            ;

            var emailAccount = _emailAccountService.GetById(model.EmailAccountId);

            if (emailAccount == null)
            {
                return new ResponseModel
                       {
                           Success = false,
                           Message = T("EmailAccount_Message_ObjectNotFound")
                       }
            }
            ;

            return(_emailAccountService.SendEmailDirectly(emailAccount, new EmailModel
            {
                From = emailLog.From,
                FromName = emailLog.FromName,
                To = emailLog.To,
                ToName = emailLog.ToName,
                CC = emailLog.CC,
                Bcc = emailLog.Bcc,
                Subject = emailLog.Subject,
                Body = emailLog.From,
                Attachment = emailLog.Attachment
            }));
        }
Ejemplo n.º 3
0
        public async Task <ApiResult <string> > SendEmail(ResendEmailModel model, CancellationToken cancellationToken)
        {
            var user = await _userManager.FindByEmailAsync(model.Email);

            if (user == null)
            {
                throw new BadRequestException("حساب کاربری با ایمیل وارد شده یافت نشد!");
            }


            var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

            code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));

            var callbackUrl = Url.Action("ConfirmEmail", "Account", new
            {
                userId = user.Id,
                token  = code
            }, HttpContext.Request.Scheme);

            var encodedLink = HtmlEncoder.Default.Encode(callbackUrl);

            await _emailSender.SendEmailAsync(new MailRequest
            {
                ToEmail = model.Email,
                Subject = "تایید ایمیل هدف سنج",
                Body    = await EmailCreator.Create(new EmailCreatorModel
                {
                    BodyText = "برای تایید ایمیل خودتون بر روی دکمه زیر کلیک کنید",
                    Link     = encodedLink,
                    Name     = $"{user.Email.Split('@')[0]} عزیز ، سلام"
                }, _webHostEnvironment.WebRootPath, cancellationToken)
            });

            return(encodedLink);
        }