logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > ASP
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 06-17-2011, 04:25 AM   #1
Johzen
 
Join Date: Jun 2011
Posts: 16
Default Contact.asp

Hi guys,

I'm looking for the possible problem of my Contact.asp, because it doesn't seem to work.

PHP Code:
<%
'----function that removes html tags-----------
   Function RemoveHTML( strText )
  Dim RegEx
  Set RegEx = New RegExp
  RegEx.Pattern = "<[^>]*>"
  RegEx.Global = True
  RemoveHTML = RegEx.Replace(strText, "")
 End Function
'
---------------------------------------------
   
'------defining script vars-------------------
   Dim mailObj, mailCfg, myBody, fld 
 Dim RegEx 
    set RegEx = New RegExp
'
--------------------------------------------
'------getting data sent by flash (filtering configuration data)------------
   For Each fld in Request.Form
      If Request.Form(fld) <> "" and _
      fld <> "mail_to" and _
   fld <> "smtp_server" and _
   fld <> "smtp_port" and _
   fld <> "plain_text" and _
   fld <> "mail_from" and _
      fld <> "mail_subject" Then
         myBody = myBody & vbCRLF & "   <b>" & fld & "</b> :<br/> " & Trim(Request.Form(fld)) & "<br/>"
      End If
   Next
'
---------------------------------------------------------------------------
'----------setting conf data------------------------------------------------
 On Error Resume Next
  Set myMail = CreateObject("CDO.Message") 
  myMail.Subject = Request.Form("mail_subject")
  myMail.From =Request.Form("mail_from")
  myMail.To = Request.Form("mail_to")
  
'
--------if plain text is set to true removing html---------------------------------------  
  if 
Request.Form("plain_text") = "true" then 
   
   myMail
.TextBody RemoveHTML(myBody)
'-------otherwise composing message body--------------------------------------------------   
   else myMail.HTMLBody = "<html><body>" & myBody & "</body></html>"
   
  end if
'
----------setting configuration params for smtp----------------------------------------------------------------------------------
  
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
  myMail
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Request.Form("smtp_server")
  
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = Request.Form("smtp_port")
  
myMail.Configuration.Fields.Update 
'---------------------------------------------------------------------------------------------------------------------------------  
  myMail.Send '
---------------sending message
  
   
If Err 0 Then
   Response
.Write("&mail=1"'if there the message is sent return 1 to flash
   Else
   Response.Write("&mail=0") '
otherwise return 0
   End 
If
   
%> 
And thanks in advance for the welcome comments, and the answers ^^
Johzen is offline   Reply With Quote
Old 06-17-2011, 06:41 AM   #2
Johzen
 
Join Date: Jun 2011
Posts: 16
Default

Quote:
Originally Posted by Johzen View Post
Hi guys,

I'm looking for the possible problem of my Contact.asp, because it doesn't seem to work.

PHP Code:
<%
'----function that removes html tags-----------
   Function RemoveHTML( strText )
  Dim RegEx
  Set RegEx = New RegExp
  RegEx.Pattern = "<[^>]*>"
  RegEx.Global = True
  RemoveHTML = RegEx.Replace(strText, "")
 End Function
'
---------------------------------------------
 
'------defining script vars-------------------
   Dim mailObj, mailCfg, myBody, fld 
 Dim RegEx 
    set RegEx = New RegExp
'
--------------------------------------------
'------getting data sent by flash (filtering configuration data)------------
   For Each fld in Request.Form
      If Request.Form(fld) <> "" and _
      fld <> "mail_to" and _
   fld <> "smtp_server" and _
   fld <> "smtp_port" and _
   fld <> "plain_text" and _
   fld <> "mail_from" and _
      fld <> "mail_subject" Then
         myBody = myBody & vbCRLF & "   <b>" & fld & "</b> :<br/> " & Trim(Request.Form(fld)) & "<br/>"
      End If
   Next
'
---------------------------------------------------------------------------
'----------setting conf data------------------------------------------------
 On Error Resume Next
  Set myMail = CreateObject("CDO.Message") 
  myMail.Subject = Request.Form("mail_subject")
  myMail.From =Request.Form("mail_from")
  myMail.To = Request.Form("mail_to")
 
'
--------if plain text is set to true removing html---------------------------------------  
  if 
Request.Form("plain_text") = "true" then 
 
   myMail
.TextBody RemoveHTML(myBody)
'-------otherwise composing message body--------------------------------------------------   
   else myMail.HTMLBody = "<html><body>" & myBody & "</body></html>"
 
  end if
'
----------setting configuration params for smtp----------------------------------------------------------------------------------
  
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
  myMail
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = Request.Form("smtp_server")
  
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = Request.Form("smtp_port")
  
myMail.Configuration.Fields.Update 
'---------------------------------------------------------------------------------------------------------------------------------  
  myMail.Send '
---------------sending message
 
   
If Err 0 Then
   Response
.Write("&mail=1"'if there the message is sent return 1 to flash
   Else
   Response.Write("&mail=0") '
otherwise return 0
   End 
If
 
%> 
And thanks in advance for the welcome comments, and the answers ^^
& What if my web host doesn't use .asp, will my contact form work? I have contact.php, send_email.php, & send_email_auto_response.php.
Johzen is offline   Reply With Quote
Old 06-19-2011, 07:31 AM   #3
Johzen
 
Join Date: Jun 2011
Posts: 16
Default

BUMP

Is this still important?
Johzen is offline   Reply With Quote
Old 06-11-2017, 11:06 AM   #4
andrewetheridge
 
Join Date: Jun 2017
Posts: 14
Default

I think this code is still important.
andrewetheridge is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:16 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com