tags:

views:

74

answers:

2

I need to send XML/HTML in an HTML email so that it displays unrendered. I'm using ASP.NET. What is the approach I should take?

+2  A: 

HTML Encode it. You can use the HttpUtility.HtmlEncode method.

Oded
+1  A: 

If I understand correctly, you want the HTML to be displayed as text and not interpreted. If so, then you can simply use the Server.HtmlEncode method to encode your string and then send that back to the browser.

...
text="<h1>Hello World</h1>";
textEncoded = Server.HtmlEncode(text);
...

<%=textEncoded%>
Ed Schembor