Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting HTML emails into datasource 1

Status
Not open for further replies.

spacemonkey125

Programmer
Jun 19, 2001
6
0
0
GB
I am building a Hotmail-style webmail application.

Most of the time, HTML messages insert into the datasource with no problems, but *sometimes* the app falls over when inserting an HTML message - hardly surprising if it's chock full of pound signs and sundry other forbidden characters.

As far as I can see, the options are to either strip out any undesirable characters from the message before inserting, or store HTML messages as separate files.

Has anyone got any tips/suggestions for dealing with this one? Any ideas would be *very* gratefully received.

TIA for your help!
 
Hi spacemonkey125,

As you said, replacing all special characters is generally a good idea.

You can use a code like this one:

HTMLEditFormat
Returns HTML escaped string. All carriage returns are removed from string, and all special characters (> < &quot; &) are escaped.

Syntax
HTMLEditFormat(string [, version ])

string
String being HTML escaped.

version
The specific HTML version to use in replacing special characters with their entity references. Valid entries are:

-1 - The latest implementation of HTML
2.0 - For HTML 2.0 (Default)
3.2 - For HTML 3.2

Haven't found a sollution for changing #.

Hope it helps you a bit further?

Kristof
 
hello again,

Think i found a solution for the #.
You should check it before it arrives at the page that sends the mail. This is easily done with JavaScript:

Code:
<html>
<head>
	<title>Untitled</title>
	<script language=&quot;JavaScript&quot;>
		function repl(form) {
			txt = form.message.value;
			txt.replace(/#/gi,&quot;#&quot;);
			form.message.value = txt;
		}
	</script>
</head>

<BODY BGCOLOR=&quot;#FFFFFF&quot; MARGINWIDTH=&quot;0&quot; MARGINHEIGHT=&quot;0&quot; LEFTMARGIN=&quot;0&quot; TOPMARGIN=&quot;0&quot;>
	<form onsubmit=&quot;repl(this)&quot; action=&quot;parse.cfm&quot; name=&quot;formulier&quot; method=&quot;post&quot;>
		<input type=&quot;text&quot; name=&quot;message&quot;>
		<input type=&quot;submit&quot; name=&quot;btSubmit&quot;>
	</form>
</body>
</html>

Hope this takes care of it :)

Gtz,

Kristof
 
Alas, i made a small typo:

txt.replace(/#/gi,&quot;#&quot;);

should be:

txt.replace(/#/gi,&quot;&#35;&quot;);

Now it should be fully correct :)

C U,

Kristof
 
sigh, i give up.

All I mean is that the second # should be the HTML entitie code. Check page source for details.

Gtz,

Kristof
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top