private async Task SendTestMail_List_ListPreRender(ComponentListEventArgs e) { var idQueryString = Request.Query["item"].ToString(); int.TryParse(idQueryString, out int id); var mailTemplate = await _mailTemplateRepository.FetchSingleAsync(id); EmailFrom = EmailFrom ?? mailTemplate.DefaultSenderEmail; EmailTo = EmailTo ?? wim.CurrentApplicationUser.Email; if (string.IsNullOrWhiteSpace(mailTemplate.Subject)) { wim.Notification.AddError("A subject is mandatory, please supply a subject before sending a test e-mail. E-mail can't be sent."); } }
private async Task ShowMailPreview_ListLoad(ComponentListEventArgs e) { var mailTemplateKey = Context.Request.Query["MailTemplateID"].ToString(); if (!string.IsNullOrEmpty(mailTemplateKey)) { var mailTemplate = await _mailTemplateRepository.FetchSingleAsync(int.Parse(mailTemplateKey)); var body = HttpUtility.HtmlDecode(mailTemplate.Body); //with the mail charset an  shows instead of  : http://stackoverflow.com/questions/1461907/html-encoding-issues-%C3%82-character-showing-up-instead-of-nbsp body = body?.Replace(@"<meta http-equiv=""Content-Type"" content=""text/html; charset=ISO-8859-1"" />", @"<meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8"" />"); var subject = mailTemplate.Subject; var text = $"<div style='margin-left:10px'><h3 style='margin-left: 50px'>{subject}</h3><p>{body}</p></div>"; var data = System.Text.Encoding.UTF8.GetBytes(text); await Response.Body.WriteAsync(data, 0, data.Length); } }