public static string CreateBodyTextForForward(Message source, bool appendSignature) { StringBuilder sb = new StringBuilder(); AppendSignature(appendSignature, sb); sb.AppendLine("<br /><br />"); sb.AppendLine("---------- Forwarded message ----------<br />"); sb.AppendFormat("From: {0}\n<br />", source.From.ToEncodedString()); sb.AppendFormat("Date: {0}\n<br />", source.DateReceived ?? source.DateSent); sb.AppendFormat("Subject: {0}\n<br />", source.Context); sb.AppendFormat("To: {0}\n<br />", source.To.ToEncodedString()); if (source.CC.Count > 0) sb.AppendFormat("CC: {0}\n<br />", source.CC.ToEncodedString()); sb.Append("<br /><br />"); var access = new ClientMessageAccess(source); var sanitizer = new HtmlSanitizer(); var sanitized = sanitizer.Sanitize(access.GetBestBodyMatch(TextConversion.ToHtml)); sb.Append(sanitized); return sb.ToString(); }
internal string GetMessageHtmlView() { var access = new ClientMessageAccess(source); var sanitizer = new HtmlSanitizer(); sanitizer.NodeVisited += SanitizerNodeVisited; var sanitized = sanitizer.Sanitize(access.GetBestBodyMatch(TextConversion.ToHtml)); return sanitized; }
static string GetMessageHtmlView(Message source) { // Hack: load core assembly directly (should be in memory anyway) Assembly asm = Assembly.LoadFrom("Inbox2.Core.Streams.dll"); //Load HTML File: Stream htmlFile = asm.GetManifestResourceStream("Inbox2.Core.Streams.ThreadView.html"); string path = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; var access = new ClientMessageAccess(source); var sanitized = HtmlSanitizer.Sanitize(access.GetBestBodyMatch(TextConversion.ToHtml)); return htmlFile.ReadString() .Replace("#rootfolder#", "file://" + path.Replace("\\", "//") + "/") .Replace("#Title#", HttpUtility.HtmlEncode(source.Context)) .Replace("#HtmlSource#", sanitized); }