protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         EmailSend        es    = new EmailSend();
         List <EmailList> eList = es.GetAllEmails();
         var FilterEmail        = eList.Where(x => x.countsent < 4 && x.emailverified == false).ToList();
         foreach (var item in FilterEmail)
         {
             MailMessage message  = new MailMessage("*****@*****.**", item.email);
             string      mailbody = $"https://localhost:44383/about.aspx?id={item.Id}";
             message.Subject      = "Introduction Email";
             message.Body         = mailbody;
             message.BodyEncoding = Encoding.UTF8;
             message.IsBodyHtml   = true;
             EmailHelper eh = new EmailHelper();
             eh.SendEmail(message);
             UpdateCountSent(item);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         closepage();
     }
 }
Esempio n. 2
0
        private void SetVerifyEmail(Guid id)
        {
            using (EmailDBContext context = new EmailDBContext())
            {
                var eList = new EmailSend().GetAllEmails()
                            .Where(x => x.Id == id && x.emailverified == false).FirstOrDefault();
                if (eList != null)
                {
                    eList.emailverified = true;

                    MailMessage message  = new MailMessage("*****@*****.**", eList.email);
                    string      mailbody = "Thank you for verifying the email";
                    message.Subject      = "Thank you Email";
                    message.Body         = mailbody;
                    message.BodyEncoding = Encoding.UTF8;
                    message.IsBodyHtml   = true;
                    EmailHelper eh = new EmailHelper();
                    eh.SendEmail(message);
                    eList.replysent = true;
                    context.Update(eList);
                    context.SaveChanges();
                }
            }
        }