//----------------------- /// <summary> /// this method gets all the emails from db that is ready to be sent and locks them for sending then try to send if fails increases the tries and id success deletes the row /// </summary> private void TrySendingEmails() { List <MailListEmailsEntity> mailsList = MailListEmailsFactory.GetAll(); foreach (MailListEmailsEntity mail in mailsList) { int id = mail.MailID; int mailMaxNoOfTries = Convert.ToInt32(SiteSettings.MailList_MailMaxNoOfTries); if (mail.Trials < mailMaxNoOfTries) { if (MailListEmailsFactory.ActualSend(mail)) { MailListEmailsFactory.Delete(id); } else { MailListEmailsFactory.IncreaseTrials(id); } } else { MailListEmailsFactory.Delete(id); } } }
//---------------------------------------------------------------------- public static void SendActivationCodeMessage(MailListUsersEntity user) { // prepare message string body = string.Format(DynamicResource.GetText("MailList", "ActivationMailBody"), new string[3] { SitesHandler.GetSiteDomain(), Encryption.Encrypt(user.UserID.ToString()), user.Email }); //string from =MailListEmailsFactory.MailFrom; MailListEmailsEntity mail = new MailListEmailsEntity(); mail.Subject = DynamicResource.GetText("MailList", "ActivationMailSubject"); mail.Body = body; mail.To.Add(user.Email); MailListEmailsFactory.Send(mail); }