Пример #1
0
        /*internal static void SendPasswordResetEmail(string email, string passwordResetToken)
        {
            string resetLink = "<a href='" + WebSettings.WebsiteDomain +
                   "Account/ResetPassword?user="******"&ver=" + passwordResetToken + "'>Reset Password</a>";
            try
            {
                MailDefinition mail = new MailDefinition();
                mail.BodyFileName = WebSettings.PasswordResetEmailTemplate;
                mail.Subject = WebSettings.PasswordResetEmailSubject;
                mail.From = WebSettings.SmtpEmailUsername;
                mail.IsBodyHtml = true;

                Dictionary<string, string> replacemets = new Dictionary<string, string>();
                replacemets.Add("#RESETLINK#", ValueToString(resetLink));

                MailMessage message = mail.CreateMailMessage(email, replacemets, new System.Web.UI.Control());

                EmailHandler handler = new EmailHandler(message);
                Thread sendEmail = new Thread(new ThreadStart(handler.SendEmail));
                sendEmail.Start();
            }
            catch (Exception)
            {
                throw;
            }
        }*/
        internal static void SendEnquiryEmail(EnquiryModel model)
        {
            try
            {
                MailDefinition mail = new MailDefinition();

                mail.From = WebSettings.EmailUsername;
                mail.Subject = WebSettings.EnquiryEmailSubject;
                mail.BodyFileName = WebSettings.EnquiryEmailTemplate;
                mail.IsBodyHtml = true;

                //ListDictionary replacements = ResetLinkToDictionary(order);
                Dictionary<string, string> replacements = new Dictionary<string, string>();
                EmailSender sender = new EmailSender();

                replacements = sender.EnquiryToDictionary(model);

                MailMessage message = mail.CreateMailMessage(WebSettings.AdminEmail, replacements, new System.Web.UI.Control());

                EmailHandler handler = new EmailHandler(message);
                Thread thread = new Thread(new ThreadStart(handler.SendEmail));
                thread.Start();
                // LoggerService.Info(HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"], "Enquiry email sent to " + WebSettings.AdminEmail);

            }
            catch (Exception)
            {
                // LoggerService.Error(e.Message, "Stack Trace: " + e.StackTrace, "");
                throw;
            }
        }
Пример #2
0
        public ViewResult Contact(EnquiryModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    EmailSender.SendEnquiryEmail(model);
                    ViewBag.Success = "Thank you for your enquiry!, Our team will contact you shortly";

                }
                catch (Exception)
                {

                    ViewBag.Error = "Unexpected error occurred; Please try again later!";
                }
                return View();

            }
            return View(model);
        }
Пример #3
0
        private Dictionary<string, string> EnquiryToDictionary(EnquiryModel model)
        {
            try
            {
                Dictionary<string, string> replacments = new Dictionary<string, string>();
                replacments.Add("#NAME#", ValueToString(model.EnquirerName));
                replacments.Add("#CONTACT#", ValueToString(model.Email));
                replacments.Add("#MESSAGE#", ValueToString(model.Message));
                return replacments;
            }
            catch (Exception)
            {

                throw;
            }
        }