Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: apostrophe fix for email


Message #1 by "Spencer Saunders" <ssaunders@i...> on Wed, 29 Aug 2001 11:20:10 -0400
Hi there.



I am trying to set up an "email this to a friend" function and 

everything is fine until the contents of the message contain an 

apostrophe. I have a function to replace apostrophe's but it doesn't 

seem to help a the case where the variable is in the body of an email.



Any ideas??



CODE:::::::::::::





 ' FUNCTION TO FX THE APOSTROPHE PROBLEM

FUNCTION theFIX(variable)

theFIX=Replace(variable, "'", "''")

END FUNCTION



DIM varaction

DIM thebody

varaction=request.form("action")

thebody=Request.form("txtBody")



  Set iConf = CreateObject _

    ("CDO.Configuration")

  Set Flds = iConf.Fields



  'Set and update fields properties

  Flds(cdoSendUsingMethod) = cdoSendUsingPort

  Flds(cdoSMTPServer) = "mail.mailserver.net"

  Flds.Update



  Set iMesg = CreateObject("CDO.Message")

  Set iMesg.Configuration = iConf



  'Format and send message

  Err.Clear



  iMesg.To = Request.Form("txtTo")

  iMesg.From = Request.Form("txtFrom")

  iMesg.Subject = Request.Form("txtSubject")

  iMesg.TextBody = theFIX(thebody)



  iMesg.Send

 

  If Err.Number = 0 Then

    Result = "Message sent"

 if varaction="send" then

  DIM vargoto

  vargoto=request.form("whereFrom")

  response.write "The article has been mailed to "& Request.form("txtTo")

  response.write "<br>This page will refresh to the article in 5 seconds." 

  'response.redirect vargoto

  end if

 

  Else

    Result = "Message not sent"

 response.write"<b>"& Ucase(Result) &"</b>"

 response.write"<br>Please check to make sure that you have entered a 

valid mail address."

 response.write"<br>This page will refresh to the article in 5 seconds"



  End If



TIA



Spencer






  Return to Index