Web Analytics Made Easy -
StatCounter Have had to change my contact form - CodingForum

Announcement

Collapse
No announcement yet.

Have had to change my contact form

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Have had to change my contact form

    Fasthosts told me last week that my contact form wont work anymore before they dont support CDONTS anymore and that I need to use cdosys instead. I have never used this and I am used to CDONTS so have no idea where to start.

    They gave me some template text which is:

    Code:
    <%
    SUB sendmail( fromWho, toWho, Subject, Body )
    Dim objCDO
    Dim iConf
    Dim Flds
    Const cdoSendUsingPort = 2
    Set objCDO = Server.CreateObject("CDO.Message")
    Set iConf = Server.CreateObject("CDO.Configuration")
    Set Flds = iConf.Fields
    With Flds
    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    .Item(cdoSMTPServer) = "213.171.216.21"
    .Item(cdoSMTPServerPort) = 25
    .Item(cdoSMTPconnectiontimeout) = 10
    .Update
    End With
    Set objCDO.Configuration = iConf
    objCDO.From = fromWho
    objCDO.To = toWho
    objCDO.Subject = Subject
    objCDO.TextBody = Body
    objCDO.Send
    END SUB
    fromWho = TRIM( Request.Form( "fromWho") )
    toWho = TRIM( Request.Form( "toWho") )
    Subject = TRIM( Request.Form( "Subject" ) )
    Body = TRIM( Request.Form( "Body") )
    IF toWho <> "" THEN
    sendMail fromWho, toWho, Subject, Body
    'Cleanup
    Set ObjCDO = Nothing
    Set iConf = Nothing
    Set Flds = Nothing
    END IF
    %>
    I assume I can swop ( Request.Form( "fromWho") ) for ("[email protected]")....

    Then when it comes to this 'body' bit, I have like 6 different parts I need to capture - so how do I get all that into the body?

    My Contact form is at www.kingsarmsbristol.com if you hit 'make a booking' a the top of the page you can see it there. the form code is:

    Code:
     <form action="thankyou.asp" name="form1" id="form1" method="post" onSubmit="MM_validateForm('email','','RisEmail','yourname','','R','youremail','','RisEmail','yourtel','','R');return document.MM_returnValue">
                <dl>
                    <dt><label for="yourname">Your name:</label></dt>
                    <dd><input name="yourname" id="yourname" style="width: 230px;" value="" type="text"></dd>
                </dl>
                <dl>
                    <dt><label for="youremail">Your email:</label></dt>
                    <dd><input name="youremail" id="youremail" style="width: 230px;" value="" type="text"></dd>
                </dl>
                <dl>
                    <dt><label for="yourtel">Your telephone:</label></dt>
                    <dd><input name="yourtel" id="yourtel" style="width: 230px;" value="" type="text"></dd>
                </dl>
                <dl>
                    <dt><label for="requiredDate">Required date:</label></dt>
                    <dd><input name="requiredDate" id="requiredDate" style="width: 130px;" value="" type="text"></dd>
              </dl>
                 <dl>
                    <dt><label for="requiredTime">Required time:</label></dt>
                    <dd><input name="requiredTime" id="requiredTime" style="width: 100px;" value="" type="text"></dd>
              </dl>
              
                 <dl>
                    <dt><label for="requiredNumber">Party size:</label></dt>
                    <dd><input name="requiredNumber" id="requiredNumber" style="width: 100px;" value="" type="text"> people</dd>
              </dl>
                           <dl>
                    <dt><label for="bookingType">Booking type:</label>
                      </dt>
                    <dd>
                      <select name="bookingType" id="bookingType">
                        <option selected="selected">Lunch</option>
                        <option>Dinner</option>
                        <option>Private Party</option>
                        <option>Wedding Reception</option>
                        <option>Business Meeting</option>
                        <option>Reserve a Table</option>
                        <option>Live Sport</option>
                        <option>Birthday Party</option>
                        <option>Networking</option>
                      </select>
                    </dd>
              </dl>                        <dl>
                    <dt><label for="bookingType">Message:</label></dt>
                    <dd>
    <textarea name="message" cols="30" rows="4"></textarea>
                </dd>
              </dl>          <dl>
              <dt></dt>
                  <dd><input name="submit" type="image" src="http://www.kingsarmsbristol.com/images/send.png" alt="Send" id="Submit" value="Submit" /></dd>
              </dl>
    </form>
    Please help!

    So i put that where my old

  • #2
    How were you getting them into the body using CDONTs??? You shouldn't need to change that.

    Show us the old code for the CDONTS body if you can't get it to work.

    ************

    The code you showed looks fine except I don't see where you define the CONSTants for the various field designators:
    Code:
    .Item([B][COLOR="Red"]cdoSendUsingMethod[/COLOR][/B]) = cdoSendUsingPort
    .Item([B][COLOR="Red"]cdoSMTPServer[/COLOR][/B]) = "213.171.216.21"
    .Item([B][COLOR="Red"]cdoSMTPServerPort[/COLOR][/B]) = 25
    .Item([B][COLOR="Red"]cdoSMTPconnectiontimeout[/COLOR][/B]) = 10
    Somewhere at the top of your ASP page you need definitions (usually done via CONST declarations) for the names in red there.
    Be yourself. No one else is as qualified.

    Comment


    • #3
      Im not sure how I define the CONTStants, I will google it lol!

      the code I previously had was:

      Code:
      <%
      
      set eMail = Server.CreateObject("CDONTS.Newmail")
      
      eMail.To = "[email protected]"
      eMail.from = "[email protected]"
      email.subject = "Website Booking Enquiry"
      
      
      strBody = "Booking Request" & chr(13)
      strBody = strBody & "Name: " & request.Form("yourname") & chr(13)
      strBody = strBody & "Email: " & request.Form("youremail") & chr(13)
      strBody = strBody & "Telephone: " & request.Form("yourtel") & chr(13)
      strBody = strBody & "Required Date: " & request.Form("requiredDate") & chr(13)
      strBody = strBody & "Required Time: " & request.Form("requiredTime") & chr(13)
      strBody = strBody & "Party Size: " & request.Form("requiredNumber") & chr(13)
      strBody = strBody & "Booking Type: " & request.Form("bookingType") & chr(13)
      strBody = strBody & "Message: " & request.Form("message") 
      
      eMail.body = strBody
      eMail.Send()
      
      set eMail = nothing

      I understand that easily! How an earth do i set up all the fields into the email?

      Comment


      • #4
        Try this as a drop in replacement for your old CDONTs code:
        Code:
        <%
        [COLOR="Magenta"]CONST sendUrl = "http://schemas.microsoft.com/cdo/configuration/sendusing"
        CONST smtpUrl = "http://schemas.microsoft.com/cdo/configuration/smtpserver"
        
        ' Set the mail server configuration
        Set objConfig = Server.CreateObject("CDO.Configuration")
        objConfig.Fields.Item(sendUrl) = 2 
        objConfig.Fields.Item(smtpUrl) = "213.171.216.21"
        ' the other fields should be fine, just using the default values
        objConfig.Fields.Update[/COLOR]
        
        ' Create and send the mail
        Set eMail = Server.CreateObject("[COLOR="Red"]CDO.Message[/COLOR]")
        [COLOR="Magenta"]' Use the config object created above
        Set eMail.Configuration = objConfig
        [/COLOR]
        eMail.To = "[email protected]"
        eMail.From = "[email protected]"
        email.subject = "Website Booking Enquiry"
        
        strBody = "Booking Request" & chr(13)
        strBody = strBody & "Name: " & request.Form("yourname") & chr(13)
        strBody = strBody & "Email: " & request.Form("youremail") & chr(13)
        strBody = strBody & "Telephone: " & request.Form("yourtel") & chr(13)
        strBody = strBody & "Required Date: " & request.Form("requiredDate") & chr(13)
        strBody = strBody & "Required Time: " & request.Form("requiredTime") & chr(13)
        strBody = strBody & "Party Size: " & request.Form("requiredNumber") & chr(13)
        strBody = strBody & "Booking Type: " & request.Form("bookingType") & chr(13)
        strBody = strBody & "Message: " & request.Form("message") 
        
        eMail.[B][COLOR="Red"]TextBody[/COLOR][/B] = strBody
        eMail.Send
        
        Set eMail = Nothing
        %>
        Additions, compared to CDONTS are in magenta.

        Changes are in red.

        Since you are sending the email as text, you need to use TextBody, not HtmlBody.
        Last edited by Old Pedant; Aug 24, 2011, 04:21 PM.
        Be yourself. No one else is as qualified.

        Comment

        Working...
        X
        😀
        🥰
        🤢
        😎
        😡
        👍
        👎