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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entering Quotation Marks in form that runs to CDONTS Screws things up!

Status
Not open for further replies.

Rexolio

Technical User
Aug 29, 2001
230
I have a form form my customers to type a message, specify an email address and then submit it. It submits to a page that sends the message to the email via CDONTS.

Problem is that whenever someone enters quotation marks, it chops off the rest of their email. I know why this is, but can't find a simply way to correct it.

I've tried:

strMsg = Request.form("Message")
strMsg = Replace(strMsg,"""","")

to remove the quotation marks, but nothing happens. If I substitute the double quotation marks for single quotation marks I get an error of course, and I can't enter the HTML equivalent (&quot) because that does nothing either.

Suggestions?
 
Incidentally, Chr(34) doesn't work either!
 
try:

strMsg = Replace(Request.form("Message"), "'", "''")
 
if that doesn't work, could you post your email processing script to get a better idea of what's happening?
 
Lobstah,

didn't work. here's my processing script:

strEmail = Request.form("youremail")
strEmail2 = Request.form("theiremail")
strSubj = Request.form("subject")
strMsg = Request.form("message")
strMsg = Replace(strMsg,"'","''") 'Lobstahs Suggestion
strGreet = Request.form("greeting")
strGreet = strGreet & ","

Dim myMail
Set myMail = Server.CreateObject("CDONTS.NewMail")
myMail.Send strEmail, strEmail2, strSubj, strGreet & vbcrlf & vbcrlf & strMsg
Set myMail = Nothing


Works just as fine as long as no one enters quotation marks.

Thanks,
Rex
 
It's double quotation marks I'm trying to get rid of.

Thanks,
rex
 
that's why my replace didn't work, i assumed you meant single quotes from the way you described it. replacing double quotes with 2 double quotes worked for me. try this:

strMsg = Relace(Request.form("message"), """, """")
 
i was just able to use double quotes in the body of a message sent using CDONTS, with the data coming from an input field in a form, with success, without having to do any replace.
can you post your form code, the form processing code, and your email code here to look at?
 
Lobstah...

I already did...its a few messages up.

Rex
 
Lobstah,

Also, the replace function (replace("message"),""","""") doesn't work.

anyone else??? Please??? :(

Rex
 
I've never used this format:
myMail.Send strEmail, strEmail2, strSubj, strGreet & vbcrlf & vbcrlf & strMsg

I always specify each property and I had no problem with the double quotes in either the subject or the body of the message:
I'm not sure if I've got all your variables in the right places, but try this:

myMail.From = strEmail
myMail.To = strEmail2
myMail.Subject = strSubj
myMail.Body = strGreet & vbcrlf & vbcrlf & strMsg
myMail.Send

 
Sorry, Lobstah. Still doesn't work. I can't beleive this is so darn hard to solve!

wow, a whole web site full of programming brainacs and no one knows a real solution to this?? C'mon guys, take up the flag...grasp the challenge!! HELP!!!!!!!! s-)
 
i just tested the above code and it worked fine for me.

before you do your send.mail, do a response.write of strgreet and strmsg to see what you have in there, maybe there's something else in your variable values....

because you are correct, this should not be this difficult....

have you tried putting constant values in the mail properties?

ie.

myMail.Body = "Hello World," & vbcrlf & "This is a test of the double""quote problem"

*(I doubled the double quotes above since the text stream would stop at the first one after the word double otherwise)
 
how are your form fields handled? is it even coming intact (beyond the double-quote) from the form? try displaying the form field that has the strMsg immediately after form submitted:

response.write Request.form("Message")

see if it's even coming from the form okay.

 
I'm not sure about this one but in Perl we use \ in front of special caracters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top