2

what i want to do is like this: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_target

but the html that will be send on iframe will be the HTMLBody of an msg file.

What I have tried:

<html>
<body>

<div id="myDiv">
<label>sample</label>
<button>send</button>
</div>
<div id="2ndHTML">
   (Insert html codes without replacing the above tags)
</div>

</body>
</html>

Default.aspx.cs:

MailItem item = (MailItem)app.CreateItemFromTemplate(@"C:\Users\elayronj\Desktop\Sample\sample.msg", Type.Missing);

samplediv.InnerHtml = item.HTMLBody;
joem824
  • 59
  • 1
  • 10
  • Why not just type them there? Are you trying to do this programmatically? Can you show the code if so? – Yacoub Massad Feb 16 '16 at 15:48
  • @JohnPaul - flagged as not-constructive. –  Feb 16 '16 at 16:34
  • 1
    Take a look at http://stackoverflow.com/questions/2820453/display-html-code-in-html. Question should be marked as a dupilcate. – John Paul Feb 16 '16 at 16:41
  • @YacoubMassad pls see default.aspx.cs for the code. Thanks. – joem824 Feb 16 '16 at 20:52
  • Can you change the template to include some value (e.g. a GUID) in the place where you want to insert the new HTML? – Yacoub Massad Feb 16 '16 at 21:50
  • It's still not clear to me if you're wanting to *display HTML within an HTML email*, or if you're wanting to *inject HTML into a template* (that maybe has the company logo, a standard footer, etc.) to construct a HTML email message. Could you clarify for us? Also, what is the type of `samplediv` in the code snippet? How is it created? – Jeff B Feb 17 '16 at 13:50
  • what i want to do is like this: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_iframe_target but the html that will be send on iframe will be the HTMLBody of an msg file. – joem824 Feb 17 '16 at 15:00

1 Answers1

0

The deprecated <xmp> tag can be used to show HTML code inside an HTML page but is no longer part of the XHTML spec. It should still work though in all current browsers.

See this working fiddle

According to the docs

The HTML Example Element () renders text between the start and end tags without interpreting the HTML in between and using a monospaced font. The HTML2 specification recommended that it should be rendered wide enough to allow 80 characters per line.

As said in the docs,

The <xmp> tag has been deprecated since HTML3.2 and was not implemented in a consistent way. It was completely removed from the language in HTML5 and to achieve the functionality, you can use

  • the <pre> element or, if semantically adequate, the <code> element instead. Note that you will need to escape the '<' character as '<' to make sure it is not interpreted as markup.
  • A monospaced font can also be obtained on any element, by applying an adequate CSS style using monospace as the generic-font value for the font-family property.
Lal
  • 14,726
  • 4
  • 45
  • 70
  • isn't the output of the tags inside xmp is in all text? – joem824 Feb 16 '16 at 16:01
  • sorry...didnt get you.. – Lal Feb 16 '16 at 16:02
  • why is the answer downvoted? – Lal Feb 16 '16 at 16:03
  • I didn't downvote, but I'm pretty sure the the guy is asking just how to escape < and >, not how to use an esoteric feature. – MatthewMartin Feb 16 '16 at 16:12
  • yeah ok..understood..but please do read my answer fully..I've explained to him, how he has to do it..without just blindly giving some links that will do the work for him..I think I was right in giving that answer..Some people get a little bit irritated when they see the word **deprecated** and they just downvotes..Anyway, thanks @MatthewMartin for taking time to read my answer.. – Lal Feb 16 '16 at 16:14
  • @Lal - things are deprecated for a reason. –  Feb 16 '16 at 16:33
  • 1
    @JᴀʏMᴇᴇ could you please explain to me, the reason why the tag is deprecated.. – Lal Feb 16 '16 at 16:50
  • @Lal - why? You've missed the point. It is deprecated, i.e. not supported - and strongly recommended that nobody chooses to use it going forward. So why answer a question with a suggestion to use it? Also, forget about the fact it's deprecated - it's horrible. For another dev approaching extensive use of this tag - it becomes increasingly complex to draw the line between mark-up and xmp content. Your jsFiddle demonstrates this nicely. –  Feb 16 '16 at 17:01
  • Sorry @JᴀʏMᴇᴇ you are totally mistaken..AS you can see in my answer, I've told the OP that the deprecated tag could have solved his issue and since its deprecated he have to use some other tags in-order to achieve the functionality..Still dont understand where I'm wrong..Is it just because I have used the word "deprecated" ? – Lal Feb 16 '16 at 17:05
  • I quote - "It should still work though in all current browsers. See this working fiddle". If that's not suggesting to use it I don't know what is. –  Feb 17 '16 at 08:54
  • That is what is true @JᴀʏMᴇᴇ ...Is saying truth in SO such a big crime? – Lal Feb 17 '16 at 16:33
  • @Lal - don't be dramatic –  Feb 17 '16 at 16:35
  • really awkward @JᴀʏMᴇᴇ .. – Lal Feb 17 '16 at 16:36