<feed xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US">
    <title>Charlie Kilian</title>
    <link rel="self" type="application/xml" href="http://geekswithblogs.net/codenfreude/Atom.aspx" />
    <subtitle type="html">blog</subtitle>
    <id>http://geekswithblogs.net/codenfreude/Default.aspx</id>
    <author>
        <name>Charlie Kilian</name>
        <uri>http://geekswithblogs.net/codenfreude/Default.aspx</uri>
    </author>
    <generator uri="http://subtextproject.com" version="Subtext Version 0.0.0.0">Subtext</generator>
    <updated>2007-12-05T09:20:04Z</updated>
    <entry>
        <title>Joy of coding: A resurrection story</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/codenfreude/archive/2007/12/05/117397.aspx" />
        <id>http://geekswithblogs.net/codenfreude/archive/2007/12/05/117397.aspx</id>
        <published>2007-12-05T09:20:04-06:00:00</published>
        <updated>2007-12-05T09:20:04Z</updated>
        <content type="html">So I've been meaning to make this blog happen now for, what? A about a year? Heh. It's high time I got this baby off the ground. Well, let's get back into the swing of things with another fun story. This one happened to me yesterday. A client called to tell me they were having trouble with a website I'd built for them. I asked them to send me a screenshot of the error message, and what I got was a Firefox display of the standard ASP.NET error screen. In big red letters the error message read: "SQL Server does not exist or access denied." I haven't changed anything on this app in well over a year, so that came as quite a surprise. &lt;br /&gt;
&lt;br /&gt;
My thought process went as follows:&lt;br /&gt;
&lt;br /&gt;
1. Can't connect to the SQL Server? Let me try it. Hmmm, I can connect just fine from here. That's weird.&lt;br /&gt;
 &lt;br /&gt;
2. What page is having the error?  Survey.aspx ... hmmm, I don't remember writing that. Let me check in the project. Weird, it isn't there.&lt;br /&gt;
 &lt;br /&gt;
3. Wait a sec, what's that "error in application /xyz" text all about? My app was called "abc". Did they move it??&lt;br /&gt;
 &lt;br /&gt;
4. Holy shit. This is a completely different URL. This isn't my site at all. &lt;br /&gt;
 &lt;br /&gt;
They called me to complain about an error on a completely different website that I've never even heard of. Ahh, clients. :)&lt;img src="http://geekswithblogs.net/codenfreude/aggbug/117397.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/codenfreude/comments/117397.aspx</wfw:comment>
        <slash:comments>0</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/codenfreude/comments/commentRss/117397.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/codenfreude/services/trackbacks/117397.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Using UserControls to create HTML emails</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/codenfreude/archive/2006/11/30/99517.aspx" />
        <id>http://geekswithblogs.net/codenfreude/archive/2006/11/30/99517.aspx</id>
        <published>2006-11-30T03:52:00-06:00:00</published>
        <updated>2006-11-30T03:52:00Z</updated>
        <content type="html">&lt;p&gt;Having written no less than two introductary posts, I suppose it's high time I wrote something worthwhile to my fellow tech bloggers. This post goes out to all the ASP.NET coders reading my blog. Both of you.&lt;/p&gt;

&lt;p&gt;If you've created more than a few websites, you probably know that sending an email is a requirement in almost every site you'll ever be asked to build. It's such a ubiquitous feature that it's even a part of the simplest practical website to actually require server side scripting: the form mailer. And while sometimes plain text emails will suffice, other times the situation calls for the prettier presentation of HTML emails.&lt;/p&gt;

&lt;p&gt;If you're like me, you'll find that a lot of your code resembles this:&lt;/p&gt;

&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white;"&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt; html = &lt;span style="color: maroon;"&gt;""&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;lt;html&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;head&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;style type=\"text/css\"&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; body,td \n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; font: 12pt Arial; \n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/style&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/head&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;lt;body&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;lt;div id=\"thanksdiv\"&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"Thank you for your order!\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;lt;/div&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;lt;div id=\"bodydiv\"&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;lt;table border=\"0\" cellspacing=\"0\" cellpadding=\"0\"&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; html += &lt;span style="color: maroon;"&gt;"&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;\n"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; html;&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;There are two big problems with this approach. The first is time of development: first, you have to write &amp; test the HTML. Then, you have to convert it into code, inserting the code to append a string, escape all the embedded double quotes, and close the string. The second problem is maintenance. What happens if you need to change the email?&lt;/p&gt;

&lt;p&gt;What would be ideal is if you could have the flexibility of using Visual Studio's HTML preview functions, while still maintaining the ability to send the email as a string. Enter an unorthodox use of UserControls.&lt;/p&gt;

&lt;p&gt;Instead of dynamically building a string that hardcodes the body of the email, put the HTML in a UserControl, like this:&lt;/p&gt;

&lt;p&gt;EmailBody.ascx:&lt;/p&gt;

&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="background: yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue;"&gt;@&lt;/span&gt; &lt;span style="color: maroon;"&gt;Control&lt;/span&gt; &lt;span style="color: red;"&gt;Language&lt;/span&gt;&lt;span style="color: blue;"&gt;="C#"&lt;/span&gt; &lt;span style="color: red;"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color: blue;"&gt;="true"&lt;/span&gt; &lt;span style="color: red;"&gt;CodeFile&lt;/span&gt;&lt;span style="color: blue;"&gt;="EmailBody.ascx.cs"&lt;/span&gt; &lt;span style="color: red;"&gt;Inherits&lt;/span&gt;&lt;span style="color: blue;"&gt;="EmailBody"&lt;/span&gt; &lt;span style="background: yellow;"&gt;%&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;html&lt;/span&gt; &lt;span style="color: red;"&gt;xmlns&lt;/span&gt;&lt;span style="color: blue;"&gt;="http://www.w3.org/1999/xhtml"&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;Page Title&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;title&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;style&lt;/span&gt; &lt;span style="color: red;"&gt;type&lt;/span&gt;&lt;span style="color: blue;"&gt;="text/css"&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: maroon;"&gt;body&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;font&lt;/span&gt;: &lt;span style="color: blue;"&gt;12pt&lt;/span&gt; &lt;span style="color: blue;"&gt;Arial&lt;/span&gt;; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;color&lt;/span&gt;: &lt;span style="color: blue;"&gt;red&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;style&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;head&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;h3&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;Thank you for your order!&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;h3&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;p&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;Your email address is &lt;span style="background: yellow;"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;EmailAddress &lt;span style="background: yellow;"&gt;%&amp;gt;&lt;/span&gt;.&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;p&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;body&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;html&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;

EmailBody.cs:

&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white;"&gt;
&lt;p style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;EmailBody&lt;/span&gt; : System.Web.UI.&lt;span style="color: teal;"&gt;UserControl&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;{&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; email = &lt;span style="color: maroon;"&gt;""&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; EmailAddress&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;get&lt;/span&gt; { &lt;span style="color: blue;"&gt;return&lt;/span&gt; email; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;set&lt;/span&gt; { email = &lt;span style="color: blue;"&gt;value&lt;/span&gt;; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;}&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;To get the body of the email, rendering the UserControl to a string using this method:&lt;/p&gt;

&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white;"&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;static&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; GetEmailBody(&lt;span style="color: teal;"&gt;UserControl&lt;/span&gt; ctl)&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;StringBuilder&lt;/span&gt; sb = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;StringBuilder&lt;/span&gt;();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;StringWriter&lt;/span&gt; sw = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;StringWriter&lt;/span&gt;( sb );&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;HtmlTextWriter&lt;/span&gt; htw = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: teal;"&gt;HtmlTextWriter&lt;/span&gt;( sw );&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ctl.RenderControl( htw );&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;return&lt;/span&gt; sb.ToString();&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;When it's time to send the email, get the body of the desired user control like this:&lt;/p&gt;

&lt;div style="font-family: Courier New; font-size: 9pt; color: black; background: white;"&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: teal;"&gt;EmailBody&lt;/span&gt; email = (&lt;span style="color: teal;"&gt;EmailBody&lt;/span&gt;) LoadControl(&lt;span style="color: maroon;"&gt;"~/EmailThankYou.ascx"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; email.EmailAddress = &lt;span style="color: maroon;"&gt;"charliekilian@gmail.com"&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;string&lt;/span&gt; body = EmailManager.GetEmailBody((&lt;span style="color: teal;"&gt;UserControl&lt;/span&gt;) email);&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Note how we set the necessary properties to render the control properly.&lt;/p&gt;

&lt;p&gt;That's it! I hope you find this tip useful!&lt;/p&gt;&lt;img src="http://geekswithblogs.net/codenfreude/aggbug/99517.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/codenfreude/comments/99517.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/codenfreude/comments/commentRss/99517.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/codenfreude/services/trackbacks/99517.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Fun with tech support</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/codenfreude/archive/2006/11/29/99433.aspx" />
        <id>http://geekswithblogs.net/codenfreude/archive/2006/11/29/99433.aspx</id>
        <published>2006-11-29T14:42:00-06:00:00</published>
        <updated>2006-11-29T15:14:00Z</updated>
        <content type="html">&lt;p&gt;This happened to me six months ago. I've been saving it as an introductary type post for Cödenfreude ever since. Never mind the fact that I already wrote an introduction. *waves hands* Pay no attention to the mand behind the curtain! There is nothing to see here! Um, except this story I'm about to tell.&lt;/p&gt;

&lt;p&gt;This is a live chat support with a Register.com representative. Keep in mind, I had to enter my email address before I could even establish a chat session.&lt;/p&gt;

&lt;p&gt;
Peter S: Thank you for visiting Register.com's Live Support.  How can I help you?&lt;br /&gt;
Charlie: I am trying to set my DNS servers to use a two third party servers.&lt;br /&gt;
Charlie: I am getting the following error message: rahvin.tk2.com is an invalid format for a DNS name&lt;br /&gt;
Charlie: why am i getting this?&lt;br /&gt;
Charlie: rahvin.tk2.com is the primary server, ns2.afraid.org is the secondary.&lt;br /&gt;
Peter S: Please let me know your domain name.&lt;br /&gt;
Charlie: longlastinglinks.com&lt;br /&gt;
Peter S: Thank you for the domain name. Please give me a few minutes while I check the records for you.&lt;br /&gt;
Peter S: Thank you for waiting.&lt;br /&gt;
Peter S: Please let me know the DNS servers you wish to keep.&lt;br /&gt;
Charlie: Didn't I just tell you that?&lt;br /&gt;
Charlie: rahvin.tk2.com is the primary, and ns2.afraid.org is the secondary&lt;br /&gt;
Peter S: Charlie, I am sorry the name server which you wish to keep are not in right format.&lt;br /&gt;
Charlie: what does that even mean?&lt;br /&gt;
Peter S:  rahvin.tk2.com name server is not yet registered.&lt;br /&gt;
Charlie: with who?&lt;br /&gt;
Peter S: Can you paste the name server setting information which you got from your Hosting company?&lt;br /&gt;
Charlie: yes&lt;br /&gt;
Charlie: it's rahvin.tk2.com, the IP is 158.247.218.187.&lt;br /&gt;
Charlie: and ns2.afraid.org, the IP is 69.94.1331.63.&lt;br /&gt;
Peter S: Can you please log in to your Account manager?&lt;br /&gt;
Charlie: Done. I'm there.&lt;br /&gt;
Peter S: Okay.&lt;br /&gt;
Peter S: Please click on the domain name for which you wish to change the name server entries.&lt;br /&gt;
Charlie: done.&lt;br /&gt;
Peter S: And once you click please scroll down now.&lt;br /&gt;
Charlie: done.&lt;br /&gt;
Peter S: Can you see the option ADVANCED TECHNICAL SETTINGS ?&lt;br /&gt;
Peter S: It is at the bottom.&lt;br /&gt;
Charlie: yes&lt;br /&gt;
Peter S: Now please click on the "Manage Registered Name Servers".&lt;br /&gt;
Charlie: done, i'm there.&lt;br /&gt;
Peter S: Please wait.&lt;br /&gt;
Peter S: Please wait.&lt;br /&gt;
Peter S: Can you please answer the secret question on file?&lt;br /&gt;
Peter S: [question redacted by Charlie]&lt;br /&gt;
Charlie: [answer redacted by Charlie]&lt;br /&gt;
Peter S: Thank you for verification.&lt;br /&gt;
Peter S: Please wait while I make all the changes for you.&lt;br /&gt;
Charlie: um&lt;br /&gt;
Charlie: but i want to know how to make them myself.&lt;br /&gt;
Peter S: Thank you for waiting.&lt;br /&gt;
Peter S: Charlie, I will have to forward your request to our appropriate department.&lt;br /&gt;
Peter S: Please be assured they will be contacting you soon with all the information.&lt;br /&gt;
Peter S: They will be contacting you through email.&lt;br /&gt;
Peter S: Please let me know by which email address you wish to be contacted.&lt;br /&gt;
Charlie: charliekilian@gmail.com&lt;br /&gt;
Charlie: i have another question for you&lt;br /&gt;
Peter S: Yes please.&lt;br /&gt;
Charlie: what color is your hair?&lt;br /&gt;
Charlie: consider that a turing test.&lt;br /&gt;
Peter S: Sorry, please explain.&lt;br /&gt;
Charlie: actually, that answers my question perfectly adequately.&lt;br /&gt;
Charlie: thanks!&lt;br /&gt;
&lt;/p&gt;&lt;img src="http://geekswithblogs.net/codenfreude/aggbug/99433.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/codenfreude/comments/99433.aspx</wfw:comment>
        <slash:comments>4</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/codenfreude/comments/commentRss/99433.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/codenfreude/services/trackbacks/99433.aspx</trackback:ping>
    </entry>
    <entry>
        <title>Introducing Cödenfreude!</title>
        <link rel="self" type="text/html" href="http://geekswithblogs.net/codenfreude/archive/2006/11/29/99432.aspx" />
        <id>http://geekswithblogs.net/codenfreude/archive/2006/11/29/99432.aspx</id>
        <published>2006-11-29T14:36:00-06:00:00</published>
        <updated>2006-11-29T14:44:00Z</updated>
        <content type="html">&lt;p&gt;Hello! My name is Charlie Kilian.  Welcome to my new tech blog, Cödenfreude! I've blogged before as a political blogger. Chances are, though, that you don't actually care about that. If I'm wrong, well, Google is your friend.&lt;/p&gt;

&lt;p&gt;I should probably introduce myself. I'm a software developer from Omaha, Nebraska. I specialize in .NET development -- both Windows Forms and ASP.NET, though recently my focus has been on the latter. I work for &lt;a href="http://www.lutzsoftware.com"&gt;Lutz Software&lt;/a&gt;, which is a division of the accounting firm &lt;a href="http://www.lutzcpa.com"&gt;Lutz &amp;amp; Company&lt;/a&gt;. In our tech group, there are currently about 13 people. Of those, only about five of us are what you'd call pure programmers. And of those, only one -- me -- focuses on .NET development. Everyone else works in VBA with Microsoft Access. But with time that will be changing.&lt;/p&gt;

&lt;p&gt;If you've noticed that my company is a pure Microsoft shop, well, you're right. But I've been known to dabble in Linux and such technologies before. For one thing, I own one of &lt;a href="http://www.mythtv.org"&gt;these&lt;/a&gt;, which I highly recommend. Back in the day (which was, um, 1998), I broke into the technology industry as a sysadmin working for &lt;a href="http://www.kansas.net"&gt;KansasNet&lt;/a&gt;. Almost everything there was Linux based, and that's how I  I got my start in web development writing Perl for Apache web servers. After that, I transitioned to Frontier Consulting Group in Manhattan, Kansas, working on VB6 and ASP using Access and SQL Server as a backend, before moving on to found Aphelion Studios in Wamego, Kansas. There, we moved back to the cheaper Linux development, specializing in PHP with a MySQL backend.&lt;/p&gt;

&lt;p&gt;But for the last three and a half years, it's been all Microsoft, all the time. When I first started at Lutz, that also meant all Access, all the time. Since I personally hate Microsoft Access with the burning passion of a thousand firey suns, when I had the opportunity to transition into the .NET world, I jumped at it. I'm currently working on growing our .NET operations. For now, it's just me, working as a jack of all trades, starting from database design and working all the way through to final release at the end of the development cycle. I'm also doing a lot of .NET work on the side, which I'm sure I'll be writing about. Notably, I'm doing some development on &lt;a href="http://www.nettiers.com"&gt;NetTiers&lt;/a&gt;, a set of templates for &lt;a href="http://www.codesmithtools.com"&gt;Codesmith&lt;/a&gt; that are used to generate a kickass DAL and BLL&lt;/p&gt;.

&lt;p&gt;This concludes your friendly host's introduction. I do hope you'll check back and leave lots of comments. Nothing warms a blogger's heart (and ego!) like feedback.&lt;/p&gt;&lt;img src="http://geekswithblogs.net/codenfreude/aggbug/99432.aspx" width="1" height="1" /&gt;</content>
        <wfw:comment>http://geekswithblogs.net/codenfreude/comments/99432.aspx</wfw:comment>
        <slash:comments>1</slash:comments>
        <wfw:commentRss>http://geekswithblogs.net/codenfreude/comments/commentRss/99432.aspx</wfw:commentRss>
        <trackback:ping>http://geekswithblogs.net/codenfreude/services/trackbacks/99432.aspx</trackback:ping>
    </entry>
</feed>
