Пример #1
0
        public void SendEmailToAdmin(RequestViewModel request, long caseId, List<string> imagesList)
        {
            // Send email to fyxme admin
            Email email = new Email(WebConfigurationManager.AppSettings["EmailSmtpHost"].ToString());
            email.From = WebConfigurationManager.AppSettings["EmailFrom"].ToString();
            email.Port = Convert.ToInt32(WebConfigurationManager.AppSettings["EmailPort"].ToString());
            email.NetworkCredentialUser = WebConfigurationManager.AppSettings["EmailNetworkCredentialUser"].ToString();
            email.NetworkCredentialPassword = WebConfigurationManager.AppSettings["EmailNetworkCredentialPassword"].ToString();
            email.To = WebConfigurationManager.AppSettings["EmailAdmin"].ToString();
            email.Subject = "You've received a new request! - Fyxme.com";

            // Get HTML template for Admin Request Received confirmation
            StreamReader sr = new StreamReader(Server.MapPath("~/Content/MailTemplates/MailSendAdminConfirmRequestReceived.html"));
            string htmlMailTemplate = sr.ReadToEnd();

            htmlMailTemplate = htmlMailTemplate.Replace("{0}", "http://www.fyxme.com/Content/Images/fyxmy_logo_poster_.png");
            htmlMailTemplate = htmlMailTemplate.Replace("{1}", caseId.ToString());
            htmlMailTemplate = htmlMailTemplate.Replace("{2}", request.FirstName.ToUpper());
            htmlMailTemplate = htmlMailTemplate.Replace("{3}", request.LastName.ToUpper());
            htmlMailTemplate = htmlMailTemplate.Replace("{4}", request.Email);
            htmlMailTemplate = htmlMailTemplate.Replace("{5}", request.PhoneNumber);
            htmlMailTemplate = htmlMailTemplate.Replace("{6}", request.ZipCode);
            htmlMailTemplate = htmlMailTemplate.Replace("{7}", request.SelectedCarMakerId);
            htmlMailTemplate = htmlMailTemplate.Replace("{8}", request.SelectedCarModelId);
            htmlMailTemplate = htmlMailTemplate.Replace("{9}", request.SelectedCarYearId);
            htmlMailTemplate = htmlMailTemplate.Replace("{10}", request.DamageDescription);

            string pics = "";
            foreach (string uploadedImage in imagesList)
            {
                pics += "<a href='http://" + Request.Url.Authority + "/Content/Upload/Pictures/" + uploadedImage + "'>http://" + Request.Url.Authority + "/Content/Upload/Pictures/" + uploadedImage + " </a><br/>";
            }

            htmlMailTemplate = htmlMailTemplate.Replace("{11}", pics);

            email.Body = htmlMailTemplate;
            email.Send();
        }
Пример #2
0
        public void SendEmailToClient(RequestViewModel request, long caseId)
        {
            // Send email to client
            Email email = new Email(WebConfigurationManager.AppSettings["EmailSmtpHost"].ToString());
            email.From = WebConfigurationManager.AppSettings["EmailFrom"].ToString();
            email.Port = Convert.ToInt32(WebConfigurationManager.AppSettings["EmailPort"].ToString());
            email.NetworkCredentialUser = WebConfigurationManager.AppSettings["EmailNetworkCredentialUser"].ToString();
            email.NetworkCredentialPassword = WebConfigurationManager.AppSettings["EmailNetworkCredentialPassword"].ToString();
            email.To = request.Email;
            email.Subject = "We've received your request! - Fyxme.com";

            // Get HTML template for Lead Request Received confirmation
            StreamReader sr = new StreamReader(Server.MapPath("~/Content/MailTemplates/MailSendLeadConfirmRequestReceived.html"));
            string htmlMailTemplate = sr.ReadToEnd();

            //htmlMailTemplate = htmlMailTemplate.Replace("{0}", Server.MapPath("~/Content/Images/fyxmy_logo_poster_.png"));
            htmlMailTemplate = htmlMailTemplate.Replace("{0}", "http://www.fyxme.com/Content/Images/fyxmy_logo_poster_.png");
            htmlMailTemplate = htmlMailTemplate.Replace("{1}", request.FirstName.ToUpper());
            htmlMailTemplate = htmlMailTemplate.Replace("{2}", request.LastName.ToUpper());
            htmlMailTemplate = htmlMailTemplate.Replace("{3}", caseId.ToString());
            htmlMailTemplate = htmlMailTemplate.Replace("{4}", request.Email);
            htmlMailTemplate = htmlMailTemplate.Replace("{5}", request.PhoneNumber);
            htmlMailTemplate = htmlMailTemplate.Replace("{6}", request.DamageDescription);

            email.Body = htmlMailTemplate;
            email.Send();
        }