public string BuildBody(EmailFormDTO email)
        {
            string environmentPath = EnvironmentUtil.Environment.WebRootPath;

            string emailHtmlTemplate = File.ReadAllText(environmentPath + "\\EmailTemplates\\mailTemplate.html");

            /*string body = "Firma: " + _email.Company + Environment.NewLine +
             *  "E-mail: " + _email.Email + Environment.NewLine +
             *  "Imie: " + _email.Name + Environment.NewLine +
             *  "Telefon: " + _email.Phone + Environment.NewLine +
             *  "Treść: " + _email.Text + Environment.NewLine; */


            string body = emailHtmlTemplate.Replace("{company}", email.Company)
                          .Replace("{email}", email.Email)
                          .Replace("{name}", email.Name)
                          .Replace("{phone}", email.Phone)
                          .Replace("{text}", email.Text);

            return(body);
        }
Ejemplo n.º 2
0
        public async Task <bool> FinishEmployeeContract([FromBody] EmailFormDTO emailSource)
        {
            try
            {
                string emailHtmlTemplate = System.IO.File.ReadAllText("EmailTemplates\\mailTemplate.html");

                string emailResponseTemplate = System.IO.File.ReadAllText("EmailTemplates\\responseTemplate.html");


                string emailBody = emailHtmlTemplate.Replace("{company}", emailSource.Company)
                                   .Replace("{email}", emailSource.Email)
                                   .Replace("{name}", emailSource.Name)
                                   .Replace("{phone}", emailSource.Phone)
                                   .Replace("{text}", emailSource.Text);

                string emailSubject = $@"Nowa wiadomość ze strony: {emailSource.Subject}";

                string responseBody = emailResponseTemplate.Replace("{text}", "Otrzymaliśmy Twoją wiadomość. Dostarczymy odpowiedź w ciągu 24 godzin!");

                string responseSubject = "BWG | Otrzymaliśmy Twoją wiadomość ze strony bwg.com.pl";

                NotificationEmailSender emailSender = new NotificationEmailSender();

                await emailSender.SendEmailAsync("*****@*****.**", emailSubject, emailBody);

                await emailSender.SendEmailAsync("*****@*****.**", emailSubject, emailBody);

                await emailSender.SendEmailAsync(emailSource.Email, responseSubject, responseBody);


                return(true);
            }
            catch (Exception)
            {
                //todo: add logging
                return(false);
            }
        }
        public string BuildSubject(EmailFormDTO email)
        {
            string subject = $@"Nowa wiadomość ze strony: {email.Subject}";

            return(subject);
        }