string GetOutput(EmailViewResult result, string format = null) { using (var writer = new StringWriter()) { result.ExecuteResult(writer, format); return(writer.GetStringBuilder().ToString()); } }
async Task <string> GetOutput(EmailViewResult result, string template, string textTemplate = null, string htmlTemplate = null, string format = null) { var actionContext = GetActionContext(GetRender(result.Email, template, textTemplate, htmlTemplate)); if (!string.IsNullOrWhiteSpace(format)) { actionContext.HttpContext.Request.QueryString = new QueryString("?format=" + format); } await result.ExecuteResultAsync(actionContext); var body = ReadBody(actionContext.HttpContext.Response); return(body); }
public void ReplaceLinkedImagesWithEmbeddedImages_replaces_cid_reference_with_correct_mime() { var embedder = new ImageEmbedder(); var resource = embedder.ReferenceImage("postal.png"); string body = "<img src=\"cid:" + resource.ContentId + @"""/>"; var view = AlternateView.CreateAlternateViewFromString(body); embedder.AddImagesToView(view); string replaced = EmailViewResult.ReplaceLinkedImagesWithEmbeddedImages(view, body); Assert.Contains("data:image/png;base64,", replaced); }
string GetOutput(EmailViewResult result, string format = null) { using (var writer = new StringWriter()) { result.ExecuteResult(writer, format); return writer.GetStringBuilder().ToString(); } }