PDA

View Full Version : Email


ooiooipig
04-14-2003, 08:22 AM
Hi all, can anyone here help me with my problem??
I'm writing an asp code to send email to the administrator when the user has submitted the form. It goes on well except there's one error. When the user enter something like this in the ReqTitle field: "Please do not use your friend's password", it is reflected in the email as "Please do not use your friend' 's password"

It shows TWO single quotation inside the email instead the original one which is single quotation. Can anyone please advise me on how to get rid of the extra quotation??

thanks!!

ps: before it is submitted into the database, it is being trimmed and replace as this: vreqTitle = replace(trim(Request("vreqTitle")),"'","''")
so that it can be entered into the database without any error.


my code is as shown below:

Set Mailobj = Server.CreateObject("CDONTS.NewMail")

Mailobj.From = "ConBiz IS Request (" & vReqtrEmail & ")"
Mailobj.To = vApprovEmail
Mailobj.Bcc = "wenxiang@singtel.com"
Mailobj.Subject = "New IS Request for Approval"
Mailobj.Body = "Hi " & vApprovOfficer & "!" & vbCrLf & vbCrLf & _
"Request Type: " & ReqDesc & "" & vbCrLf & _
"Application Name: " & vAppnId & "" & vbCrLf & _
"Request No: " & ReqNo & "" & vbCrLf & _
"Request Title: " & vreqTitle & "" & vbCrLf & _
"Requestor: " & vReqtr & "" & vbCrLf & vbCrLf & vbCrLf &_
"Please click on the embedded hyperlink below to endorse the request." & vbCrLf & _
"http://sg_05_webdev:87/default.asp" & vbCrLf

Mailobj.Send
Set Mailobj = Nothing

Spudhead
04-14-2003, 09:15 AM
Well, you've kinda answered your own question :)

vreqTitle = replace(trim(Request("vreqTitle")),"'","''")

is taking the form value: Request("vreqTitle") and replacing any ' that it finds in there with two of 'em.

so, for your email, you can simply create another variable that doesn't do the replacing thing, to use instead:

vreqTitle2 = trim(Request("vreqTitle"))

ooiooipig
04-14-2003, 09:21 AM
create another variable?? but it's still the reqTitle that i want. not another new variable... if i create another variable, won't the users have to enter another field??

when i see the database, it is correctly stored as one qoute only, but just that when sending the email, it becomes 2 quotes.

raf
04-14-2003, 09:59 AM
I've explained the quotes thingy here:

http://www.codingforums.com/showthread.php?s=&threadid=18174

The RDBM converts the two single quotes into one so in your db, it's stored as it was before the replace.


But when you mail the value of the variable, no such reprosessing (as the RDBM does) occurs and it is displayed as right after the replace.

In short, you don't need the replace for the mail


I don't think you understand what a variable is. So you'd really need to look into that. If you create a value, it is empty. You can then store a value in it + alter that value, replace it, grap a value from a from and store that in the value etc

If my client fills in a form, and he types in his name, and posts the form, well then i can grab the name he inserted and start doing all sorts on that.

Say he types in "raf"
then

dim variable1
variable1 = request.form("name") 'value of variable1 = "raf"
variable1 = replace (variable1,"a","r") 'value of variable1 = "rrf"
variable1 = "blablabla" + variable1 ' value is blablablarrf
etc

You vould just as well do something like

variable=replace(request.form,"'","''")
and use the value then in your sql statement, and use
variable=request.form("name")
for the email

david7777
04-14-2003, 10:05 AM
It seems that you are doing the right thing by replacing the single ' with double, for inserting into the database... You must do this to prevent errors. If you email from the same page as where the database entry is done, then you need to duplicate your subject before doing the replace...

ie:

... User enters info ...
... database connection set ...
... Get the subject the user entered ...
dim vreqTitle2 = vreqTitle
vreqTitle = replace(trim(Request("vreqTitle")),"'","''")
... Do database insert ...
Set Mailobj = Server.CreateObject("CDONTS.NewMail")

Mailobj.From = "ConBiz IS Request (" & vReqtrEmail & ")"
Mailobj.To = vApprovEmail
Mailobj.Bcc = "wenxiang@singtel.com"
Mailobj.Subject = "New IS Request for Approval"
Mailobj.Body = "Hi " & vApprovOfficer & "!" & vbCrLf & vbCrLf & _
"Request Type: " & ReqDesc & "" & vbCrLf & _
"Application Name: " & vAppnId & "" & vbCrLf & _
"Request No: " & ReqNo & "" & vbCrLf & _
"Request Title: " & vreqTitle2 & "" & vbCrLf & _
"Requestor: " & vReqtr & "" & vbCrLf & vbCrLf & vbCrLf &_
"Please click on the embedded hyperlink below to endorse the request." & vbCrLf & _
"http://sg_05_webdev:87/default.asp" & vbCrLf

Mailobj.Send
Set Mailobj = Nothing

Hope that helped
:cool:

ooiooipig
04-14-2003, 10:14 AM
hey raf!! thanks alot!! it's done!! :)
david, yah, i followed the way raf said.

ReqTitle = request.form("vreqTitle")

thanks alot to the both of you!!

raf
04-14-2003, 10:18 AM
your welcome. glad you got that running :thumbsup:

david7777
04-14-2003, 10:20 AM
Oops - Our posts must have crossed...:D