private static MailContent createVendorReportEmail(Vendor vendor, String recipient, UserPurchase user, int categoryId)
        {
            MailContent mailContent = new MailContent();
            mailContent.MailFrom = vendorsContactEmail;
            mailContent.MailingAdress = recipient;
            QuestionnaireContext _context = new QuestionnaireContext();
            String sectionName = (categoryId != 0 ) ? _context.Categories.Where(x => x.Id == categoryId).First().Title
                : "General List of ‘Suggested Service Providers’";

            mailContent.Subject = "Referral from AFFI-FSMA Assessments – Request for Information";
            mailContent.HtmlText = "<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" style=\"width: 600px;\">"
                + "<tbody><tr><td>"
                + "<img alt=\"\" src=\"http://affi-fsma.seneca.com/Content/img/affi_logo.jpg\" style=\"width: 100px; height: 73px;\" /></td>"
                + "<td><div><span style=\"font-size:18px;\"><strong>Responses from the AFFI &ndash; FSMA Self Assessment</strong></span></div>"
                + "<div><span style=\"font-size:18px;\"><strong>Request for Information to &ldquo;Suggested Service Provider&rdquo;</strong></span></div>"
                + "</td></tr></tbody></table><br/>"
                + "<span style=\"font-size:16px;\">TO: " + vendor.Name + "<br/><br/>"
                + "The following person has clicked on the “Contact Me” button while taking the AFFI – FSMA Self-Assessment:<br/><br/>"
                + "Name of person: " + user.Name + "<br/>"
                + "Facility name: " + user.FacilityName + "<br/>"
                + "Email address: " + user.Email + "<br/>"
                + "Date and time: " + DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString() + "<br/><br/>"
                + "Section of the AFFI – FSMA Self-Assessment Report: " + sectionName + "<br/><br/>"
                + "By clicking on the Contact Me button the person anticipates that they will receive information about your company’s services related to the section of the FSMA Self-Assessment Report as referenced above.<br/><br/>"
                + "If you have any questions about this email, please “Reply” to this email with your questions.<br/><br/>"
                + "Thank you – <br/>"
                + "Seneca Corporation</span>";
            return mailContent;
        }
Ejemplo n.º 2
0
        internal static void sendEmailToUser(string email, Product.ProudctType productType)
        {
            var emailServer = getSMTPServer();
            IMailService mailService = new SmptMailService(emailServer);

            MailContent mail = new MailContent();
            mail.MailingAdress = email;
            mail.MailFrom = getFromAddress();
            mail.ReplyToAddress = getReplyToAddress();

            //AFFI English
            if(productType == Product.ProudctType.AffiEnglish)
            {
                mail.Subject = getAFFIEmailSubject();
                mail.HtmlText = getEmailBodyForUserAFFISite();
            }
            //AFFI Spanish
            else
            {
                mail.Subject = getAFFISpanishEmailSubject();
                mail.HtmlText = getEmailBodyForUserAFFISpanishSite();
            }

            mailService.sendMail(mail, true);
        }
 public static MailContent createUserReportEmail(UserPurchase user, QuestionnaireReport report)
 {
     MailContent mailContent = new MailContent();
     mailContent.MailFrom = adminEmail;
     mailContent.MailingAdress = user.Email;
     mailContent.Subject = "FSMA Self Assessment Report for " + user.FacilityName;
     return mailContent;
 }
        private MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
        {
            MailSendStatus mailSendStatus = new MailSendStatus();

            mailSendStatus.IsSended = false;
            int flag = 0;
            if (mailContent.MailingAdress == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                flag = 1;
            }
            if (mailContent.PlainText == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                flag = 1;
            }
            if (login == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Login ";
                flag = 1;
            }
            if (password == "")
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Password ";
                flag = 1;
            }

            if (flag == 0)
            {
                SmtpClient smtpclient = new SmtpClient();

                try
                {
                    var _with1 = (smtpclient);
                    _with1.Host = "Smtp.mail.ru";
                    _with1.Port = 25;
                    _with1.EnableSsl = false;
                    _with1.Credentials = new NetworkCredential(login, password);

                    MailMessage mailMessage = new MailMessage(login + "@mail.ru", mailContent.MailingAdress, mailContent.Subject, mailContent.HtmlText);
                    mailMessage.IsBodyHtml = isBodyHtml;

                    mailMessage.Body = mailContent.HtmlText;

                    smtpclient.Send(mailMessage);
                    mailSendStatus.IsSended=true;
                }
                catch (Exception ex)
                {
                    mailSendStatus.ErrorType = mailSendStatus.ErrorType + ex;
                }
            }
            return mailSendStatus;
        }
Ejemplo n.º 5
0
        public MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
        {
            MailSendStatus mailSendStatus = new MailSendStatus();

            if (String.IsNullOrEmpty(mailContent.MailingAdress))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                return(mailSendStatus);
            }
            if (String.IsNullOrEmpty(mailContent.HtmlText))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                return(mailSendStatus);
            }

            SmtpClient smtpClient = new SmtpClient(host);

            MailMessage mail = new MailMessage();

            mail.From = new MailAddress(mailContent.MailFrom);

            if (!String.IsNullOrEmpty(mailContent.ReplyToAddress))
            {
                mail.ReplyToList.Add(mailContent.ReplyToAddress);
            }


            mail.To.Add(mailContent.MailingAdress);

            mail.Subject = mailContent.Subject;

            if (!String.IsNullOrEmpty(mailContent.HtmlText))
            {
                ContentType   mimeType  = new System.Net.Mime.ContentType("text/html");
                AlternateView alternate = AlternateView.CreateAlternateViewFromString(mailContent.HtmlText, mimeType);
                mail.AlternateViews.Add(alternate);
            }

            mail.Body = mailContent.PlainText;

            if (mailContent.AttachmentPass != null)
            {
                mail.Attachments.Add(new Attachment(mailContent.AttachmentPass));
            }

            smtpClient.Send(mail);

            mailSendStatus.IsSended = true;

            return(mailSendStatus);
        }
Ejemplo n.º 6
0
        internal static void sendErrorEmail(string message)
        {
            var emailServer = getSMTPServer();
            IMailService mailService = new SmptMailService(emailServer);

            var emailRecipient = System.Configuration.ConfigurationManager.AppSettings["errorEmailRecipient"];

            MailContent mail = new MailContent();
            mail.MailingAdress = emailRecipient;
            mail.MailFrom = getFromAddress();
            mail.Subject = "AFFI Signup Error";
            mail.HtmlText = message;
            mailService.sendMail(mail, true);
        }
        public MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
        {
            MailSendStatus mailSendStatus = new MailSendStatus();
            if (String.IsNullOrEmpty(mailContent.MailingAdress))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                return mailSendStatus;
            }
            if (String.IsNullOrEmpty(mailContent.HtmlText))
            {
                mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                return mailSendStatus;
            }

            SmtpClient smtpClient = new SmtpClient(host);

            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(mailContent.MailFrom);

            if (!String.IsNullOrEmpty(mailContent.ReplyToAddress))
            {
                mail.ReplyToList.Add(mailContent.ReplyToAddress);
            }

            mail.To.Add(mailContent.MailingAdress);

            mail.Subject = mailContent.Subject;

            if (!String.IsNullOrEmpty(mailContent.HtmlText))
            {
                ContentType mimeType = new System.Net.Mime.ContentType("text/html");
                AlternateView alternate = AlternateView.CreateAlternateViewFromString(mailContent.HtmlText, mimeType);
                mail.AlternateViews.Add(alternate);
            }

            mail.Body = mailContent.PlainText;

            if (mailContent.AttachmentPass != null)
                mail.Attachments.Add(new Attachment(mailContent.AttachmentPass));

            smtpClient.Send(mail);

            mailSendStatus.IsSended = true;

            return mailSendStatus;
        }
Ejemplo n.º 8
0
        internal static void sendEmailToAffi(Product.ProudctType productType)
        {
            var emailServer = getSMTPServer();
            IMailService mailService = new SmptMailService(emailServer);

            MailContent mail = new MailContent();
            mail.MailingAdress = getAFFIToAddress();
            mail.MailFrom = getFromAddress();
            mail.ReplyToAddress = getReplyToAddress();
            //AFFI English
            //if (productType == Product.ProudctType.AffiEnglish)
            //{
                mail.Subject = getAFFIEmailSubject();
                mail.HtmlText = getEmaiBodyforAffi();
            //}
            //AFFI Spanish
            //else
            //{
            //    mail.Subject = getAFFISpanishEmailSubject();
            //    mail.HtmlText = getEmaiBodyforAffiSpanish();
            //}

            mailService.sendMail(mail, true);
        }
        public ActionResult Activate(PurchasedItemModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
                return Redirect("Index");

            string facilityName = model.Facility;
            string userName = model.Name;
            string email = model.Email;
            string dateOfPurchase = model.DateOfPurchase;
            List<PurchasedItem> purchasedItems = GetStoredPurchasedItems();
            if (purchasedItems == null)
            {
                return LogOutAndRedirectToLoginPage();
            }
            DateTime date = DateTime.Parse(dateOfPurchase);

            var purchasedItem = purchasedItems.Find(i => Math.Abs(i.DateOfPurchase.Subtract(date).TotalSeconds) < 1);

            if (purchasedItem != null)
            {
                var count = context.UserPurchases.Where(u => EntityFunctions.DiffSeconds(u.DateOfPurchase, purchasedItem.DateOfPurchase) < 1).Count();

                //if(count != 0)
                //    return Content("<html><head></head><body><h1>Error! This item already activated </h1></body></html>");

                var salt = GenerateSequenceOfChars(20);
                // TODO: check facility name length
                var password = GeneratePassword(facilityName);

                //TODO: move following code to method
                var userPurchase = new UserPurchase();

                userPurchase.Email = email;
                userPurchase.ActivatorsEmail = User.Identity.Name;
                userPurchase.Name = userName;
                userPurchase.PasswordSalt = salt;
                userPurchase.Password = HashPassword(password, salt);
                userPurchase.FacilityName = facilityName;
                userPurchase.DateOfPurchase = purchasedItem.DateOfPurchase;
                userPurchase.UserRegistrationDate = DateTime.Now;
                userPurchase.UserExpirationDate = DateTime.Now.AddMonths(6);

                context.UserPurchases.Add(userPurchase);
                context.SaveChanges();

                HttpContext.Session["lastPurchase"] = userPurchase;
                HttpContext.Session["lastPurchasePassword"] = password;

                //Send an email to user
                IMailService mailService = new SmptMailService(System.Configuration.ConfigurationManager.AppSettings["smtpServer"]);

                MailContent mailContent = new MailContent();
                mailContent.MailFrom = "*****@*****.**";
                mailContent.MailingAdress = userPurchase.Email;
                mailContent.Subject = "AFFI FSMA Self-Assessment Login Credentials and Instructions";

                mailContent.HtmlText = "<html><head></head><body>Dear " + userPurchase.Name + ":<br/>" +
                "<p>When you want to begin your FSMA Self-Assessment for your facility (<b>" + userPurchase.FacilityName + "</b>), you can just click on the Login link below.</p>" +
                "<p>Your login credentials for the FSMA Self-Assessment are: </p>" +
                "<p><b>Userid: </b>" + userPurchase.Email + "</p>" +
                "<p><b>Password: </b>" + password + "</p>" +
                "<p>If you have any questions regarding the FSMA Self-Assessment Tool, please contact AFFI Vice President of Regulatory and Technical Affairs Dr. Donna Garren at <a href=\"mailto:[email protected]\">[email protected]</a> or (703) 821-0770.</p>" +
                "<p>Thank you.</p>" +
                "<p><a href=\"http://affi-fsma.seneca.com/signIn\" target=\"_blank\">Click Here to Login</a></p></body></html>";

                mailContent.PlainText = mailContent.HtmlText;
                mailService.sendMail(mailContent);

                //And if needed - to a person who had activated the purchase (if not same person)
                if (userPurchase.Email != userPurchase.ActivatorsEmail)
                {
                    mailContent.MailingAdress = userPurchase.ActivatorsEmail;
                    mailService.sendMail(mailContent);
                }

                return Redirect("Index");
            }
            else
            {
                return Content("<html><head></head><body><h1>Error!Can't find purchasedItem</h1></body></html>");
            }
        }
Ejemplo n.º 10
0
               private MailSendStatus doSendMail(MailContent mailContent, bool isBodyHtml)
               
        {
                       MailSendStatus mailSendStatus = new MailSendStatus();

                       mailSendStatus.IsSended = false;
                       int flag = 0;

                       if(mailContent.MailingAdress == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required MailingAdress data ";
                               flag = 1;
                               
            }

                       if(mailContent.PlainText == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Text data ";
                               flag = 1;
                               
            }

                       if(login == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Login ";
                               flag = 1;
                               
            }

                       if(password == "")
                       
            {
                               mailSendStatus.ErrorType = mailSendStatus.ErrorType + "Required Password ";
                               flag = 1;
                               
            }

                       if(flag == 0)
                       
            {
                               SmtpClient smtpclient = new SmtpClient();

                               try
                                {
                                       var _with1         = (smtpclient);
                                       _with1.Host        = "Smtp.mail.ru";
                                       _with1.Port        = 25;
                                       _with1.EnableSsl   = false;
                                       _with1.Credentials = new NetworkCredential(login, password);

                    MailMessage mailMessage = new MailMessage(login + "@mail.ru", mailContent.MailingAdress, mailContent.Subject, mailContent.HtmlText);

                    mailMessage.IsBodyHtml = isBodyHtml;

                    mailMessage.Body = mailContent.HtmlText;

                    smtpclient.Send(mailMessage);
                                       mailSendStatus.IsSended = true;
                                   
                }
                               catch(Exception ex)
                               
                {
                                       mailSendStatus.ErrorType = mailSendStatus.ErrorType + ex;
                                   
                }

                           
            }

                       return mailSendStatus;
                               
        }
Ejemplo n.º 11
0
 public MailSendStatus sendMail(MailContent mailContent, bool isBodyHtml)
 {
     return(doSendMail(mailContent, isBodyHtml));
 }
Ejemplo n.º 12
0
 public MailSendStatus sendMail(MailContent mailContent)
 {
     return(doSendMail(mailContent, true));
 }
 public MailSendStatus sendMail(MailContent mailContent, bool isBodyHtml)
 {
     return doSendMail(mailContent, isBodyHtml);
 }
 public MailSendStatus sendMail(MailContent mailContent)
 {
     return doSendMail(mailContent, true);
 }