Ejemplo n.º 1
0
        public Email(EmailConfigBo senderConfig, List <string> toEmails, string subject, string body)
        {
            try
            {
                string smtpAddress = senderConfig.SmtpAddress;
                int    portNumber  = senderConfig.PortNumber;
                bool   enableSSL   = senderConfig.EnableSSL;

                string emailFrom = senderConfig.SendEmail;
                string password  = senderConfig.Password;
                using (MailMessage mail = new MailMessage())
                {
                    mail.From = new MailAddress(emailFrom);
                    foreach (var items in toEmails)
                    {
                        mail.To.Add(items);
                    }
                    mail.Subject    = subject;
                    mail.Body       = body;
                    mail.IsBodyHtml = true;
                    // Can set to false, if you are sending pure text.

                    using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                    {
                        smtp.Credentials = new NetworkCredential(emailFrom, password);
                        smtp.EnableSsl   = enableSSL;
                        smtp.Send(mail);
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 public void ForgetPasswordSendEmail(string email, string token, EmailConfigBo sender)
 {
     EmailService.WithTemplate(EmailType.ForgetPassword).Send(new RegisterEmailViewModel
     {
         Emails = new List <string>()
         {
             email
         },
         Link        = token,
         ReseverName = "User "
     }, sender);
 }
Ejemplo n.º 3
0
        public void Send <T>(T view, EmailConfigBo config) where T : class
        {
            try
            {
                EmailConfigBo = config;
                switch (Type)
                {
                case EmailType.Registration:
                    SendRegisterEmail(view as RegisterEmailViewModel);
                    break;

                case EmailType.ForgetPassword:
                    SendForgetPasswordEmail(view as ForgetPasswordEmailViewModel);
                    break;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 4
0
 public void Update(EmailConfigBo item, string id)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public EmailConfigBo Create(EmailConfigBo item)
 {
     throw new NotImplementedException();
 }