Esempio n. 1
0
        public void Print()
        {
            var path = $"{Guid.NewGuid()}.html";

            using (var html = new HtmlTextWriter(Writer))
            {
                html.Write("<!DOCTYPE html>\n");
                html.RenderBeginTag(HtmlTextWriterTag.Html);
                html.RenderBeginTag(HtmlTextWriterTag.Head);
                html.RenderBeginTag(HtmlTextWriterTag.Style);
                html.Write(css);
                html.RenderEndTag();
                html.RenderEndTag();
                html.RenderBeginTag(HtmlTextWriterTag.Body);
                html.RenderBeginTag("Header");
                html.Write(logo);
                html.AddAttribute(HtmlTextWriterAttribute.Class, "from");
                html.RenderBeginTag(HtmlTextWriterTag.Address);
                foreach (var line in Sender.Format())
                {
                    html.WriteEncodedText(line);
                    html.WriteBreak();
                }
                html.RenderEndTag();
                html.AddAttribute(HtmlTextWriterAttribute.Class, "to");
                html.RenderBeginTag(HtmlTextWriterTag.Address);
                foreach (var line in Recipient.Format())
                {
                    html.WriteEncodedText(line);
                    html.WriteBreak();
                }
                html.RenderEndTag();
                html.RenderEndTag();
                html.RenderBeginTag("Section");
                html.RenderBeginTag(HtmlTextWriterTag.P);
                html.WriteEncodedText($"{Sender?.Address?.City}, {DateTime.Today:dd MMM yyyy}");
                html.RenderEndTag();
                html.RenderBeginTag(HtmlTextWriterTag.P);
                html.WriteEncodedText($"Betreft: {Subject}");
                html.RenderEndTag();
                html.RenderEndTag();
                html.RenderBeginTag("Main");
                foreach (var p in Body)
                {
                    html.RenderBeginTag(HtmlTextWriterTag.P);
                    html.WriteEncodedText(p);
                    html.Write("&nbsp;");
                    html.RenderEndTag();
                }
                html.RenderEndTag();
                html.RenderEndTag();
                html.RenderEndTag();
            }
        }