Link to home
Start Free TrialLog in
Avatar of Chukwudebe
Chukwudebe

asked on

Adding cdosys to a contact form

Hello,

I've been given some cdosys script by my site's hosts (because my contact form suddenly started generating a 500 Internal Server Error message). They told me that I need to edit the file, add my form's fields and then redirect my form to this script to process mails. As I know NOTHING about asp, cdosys, etc, I have no idea what to do! If I paste the scripts for the cdosys file and my contact form below, is there anyone who could put them together for me?

Here's the cdosys script:

<% dim HTML,AdvisorFirstName,AdvisorLastName HTML = HTML & " <html><body>" HTML = HTML & " <table border=""0"">" HTML = HTML & " <tr>" HTML = HTML & " <th bgcolor=""#B0CDDD"">" HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2""> <b> Advisor First Name: </b> </font> </p>" HTML = HTML & " </th>" HTML = HTML & " <td bgcolor=""#B0CDDD"">" HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2"">" & Request("AdvisorFirstName") & "</p>" HTML = HTML & " </td>" HTML = HTML & " </tr>" HTML = HTML & " <tr>" HTML = HTML & " <th bgcolor=""#B0CDDD"">" HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2""> <b> Advisor Last Name: </b> </font> </p>" HTML = HTML & " </th>" HTML = HTML & " <td bgcolor=""#B0CDDD"">" HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2"">" & Request("AdvisorLastName") & "</p>" HTML = HTML & " </td>" HTML = HTML & " </tr>" HTML = HTML & " </table>" HTML = HTML & "<br>" HTML = HTML & " </body></html>" 'CDOSYS Configuration Set oMail = Server.CreateObject("CDO.Message") Set iConf = Server.CreateObject("CDO.Configuration") Set Flds = iConf.Fields 'Default parameters for Dataflame (dont change) iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost" 'Note 'Use "localhost" If mail is routed from same server. 'Use Server IP like "203.90.78.221" if Domain has MX record having IP "203.90.78.221" OR Mails are routed from that IP iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 iConf.Fields.Update Set oMail.Configuration = iConf oMail.To = "test@netpivotal.com" oMail.From = "contact@theeditplace.com" oMail.Subject = "New Email!" 'If message body is in HTML FORMAT oMail.BodyPart.ContentTransferEncoding = "quoted-printable" oMail.HTMLBody = HTML oMail.Send Set iConf = Nothing Set Flds = Nothing %> <html> Message Sent </html>

And here's my contact form's script:

<%@ Language=VBScript%><%Dim actionaction = Request.Form("action")If action = "" Then    action = Request.Querystring("action")End IfIf action = "submitContactForm" Then submitContactForm() End IfFunction submitContactForm()    Dim Name, Surname, Email, Document_Title, Other    Dim Message        'Collect the information from the submitted contact form    Name          = Request.Form("name")    Surname      = Request.Form("surname")    Email          = Request.Form("email")      Document_Title = Request.Form ("title")    Other         = Request.Form("other")        'Strip single quotes out of the contact form    Other = Replace(Other, "'", "''")         'Set up the mail message    Message = "<table>"    Message = Message & "<tr><td colspan='2' style='font-weight:bold;'>The following information has been submitted via the contact form:</td></tr>"    Message = Message & "<tr><td>Name:</td><td>" & Name & "</td></tr>"    Message = Message & "<tr><td>Surname:</td><td>" & Surname & "</td></tr>"    Message = Message & "<tr><td>Email:</td><td>" & Email & "</td></tr>"      Message = Message & "<tr><td>Document Title:</td><td>" & Document_Title & "</td></tr>"    Message = Message & "<tr><td>Other:</td><td>" & Other & "</td></tr>"    Message = Message & "</table>"        SendEmail(Message)End FunctionFunction SendEmail(Message)              '// Set up the CDO Mail Object    Set oMail = Server.CreateObject("CDO.Message")        '// Configure the Mail Server    Set oMailConfig = Server.CreateObject("CDO.Configuration")    '// Set the mail config. fields.    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60    oMailConfig.Fields.Update    Set oMail.Configuration = oMailConfig        '// Set the mail headers    oMail.From = "contact@theeditplace.com"    oMail.To = "info@theeditplace.com"    '//     oMail.Subject = "A form submission from theeditplace.com" '//    

It's a terrible thing to be completely in the dark about things like this but I'm hoping an expert will be able to shed some light on this for me.

Thank you very much.
Avatar of SquareHead
SquareHead

Well, first thing is it'd be helpful if you could post the code with the indenting intact, rather than all jammed together... Secondly, go into IE | Tools | Internet Options... | Advanced tab, and UN-check the "show friendly HTTP error messages" checkbox... Then rerun your script. You should receive an error statement that includes the line number in the code where the error occurs. Post the complete error message here if you can...
Avatar of Chukwudebe

ASKER

Dear SquareHead,

Thank you for your response. Both scripts are repasted below with indenting intact. I'm afraid I don't what you mean by "rerun" my script. I have unchecked the "show friendly HTTP error messages" checkbox.

CDOSYS SCRIPT:

<%
dim HTML,AdvisorFirstName,AdvisorLastName
HTML = HTML & " <html><body>"
HTML = HTML & " <table border=""0"">"
HTML = HTML & " <tr>"
HTML = HTML & " <th bgcolor=""#B0CDDD"">"
HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2""> <b> Advisor First Name: </b> </font> </p>"
HTML = HTML & " </th>"
HTML = HTML & " <td bgcolor=""#B0CDDD"">"
HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2"">" & Request("AdvisorFirstName") & "</p>"
HTML = HTML & " </td>"
HTML = HTML & " </tr>"
HTML = HTML & " <tr>"
HTML = HTML & " <th bgcolor=""#B0CDDD"">"
HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2""> <b> Advisor Last Name: </b> </font> </p>"
HTML = HTML & " </th>"
HTML = HTML & " <td bgcolor=""#B0CDDD"">"
HTML = HTML & " <p style=""margin-top:1;margin-bottom:1"" align=""left""> <font face=""arial"" size=""2"">" & Request("AdvisorLastName") & "</p>"
HTML = HTML & " </td>"
HTML = HTML & " </tr>"
HTML = HTML & " </table>"
HTML = HTML & "<br>"
HTML = HTML & " </body></html>"

'CDOSYS Configuration
Set oMail = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

'Default parameters for Dataflame (dont change)
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
'Note
'Use "localhost" If mail is routed from same server.
'Use Server IP like "203.90.78.221" if Domain has MX record having IP "203.90.78.221" OR Mails are routed from that IP

iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
iConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
iConf.Fields.Update
Set oMail.Configuration = iConf
oMail.To = "test@netpivotal.com"
oMail.From = "contact@theeditplace.com"
oMail.Subject = "New Email!"

'If message body is in HTML FORMAT
oMail.BodyPart.ContentTransferEncoding = "quoted-printable"
oMail.HTMLBody = HTML
oMail.Send
Set iConf = Nothing
Set Flds = Nothing
%>
<html>
Message Sent
</html>

ASP SCRIPT:

<%@ Language=VBScript%>
<%
Dim action
action = Request.Form("action")
If action = "" Then
    action = Request.Querystring("action")
End If

If action = "submitContactForm" Then submitContactForm() End If

Function submitContactForm()
    Dim Name, Surname, Email, Document_Title, Other
    Dim Message
   
    'Collect the information from the submitted contact form
    Name          = Request.Form("name")
    Surname      = Request.Form("surname")
    Email          = Request.Form("email")
      Document_Title = Request.Form ("title")
    Other         = Request.Form("other")
   
    'Strip single quotes out of the contact form
    Other = Replace(Other, "'", "''")
   
    'Set up the mail message
    Message = "<table>"
    Message = Message & "<tr><td colspan='2' style='font-weight:bold;'>The following information has been submitted via the contact form:</td></tr>"
    Message = Message & "<tr><td>Name:</td><td>" & Name & "</td></tr>"
    Message = Message & "<tr><td>Surname:</td><td>" & Surname & "</td></tr>"
    Message = Message & "<tr><td>Email:</td><td>" & Email & "</td></tr>"
      Message = Message & "<tr><td>Document Title:</td><td>" & Document_Title & "</td></tr>"
    Message = Message & "<tr><td>Other:</td><td>" & Other & "</td></tr>"
    Message = Message & "</table>"
   
    SendEmail(Message)

End Function

Function SendEmail(Message)
       
      '// Set up the CDO Mail Object
    Set oMail = Server.CreateObject("CDO.Message")
   
    '// Configure the Mail Server
    Set oMailConfig = Server.CreateObject("CDO.Configuration")

    '// Set the mail config. fields.
    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "localhost"
    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    oMailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
    oMailConfig.Fields.Update

    Set oMail.Configuration = oMailConfig
   
    '// Set the mail headers
    oMail.From = "contact@theeditplace.com"
    oMail.To = "info@theeditplace.com"    '//
    oMail.Subject = "A form submission from theeditplace.com" '//
   
    '// Set the email body
    oMail.HTMLBody = Message
   
    '// Send the email
    oMail.Send

    '//Clear the mail object and configuration fields
    Set oMail         = Nothing
    Set oMailConfig = Nothing

   
End Function


%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Contact theeditplace.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
 
<link href="style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
      margin-left: 0px;
      margin-top: 0px;
      background: url('/images/stripes4.jpg') repeat-y;
}
.style2 {font-family: Arial, sans-serif}
.style3 {color: #42487C}
-->
</style></head>

<body>
<table width="780" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="60" rowspan="4" valign="top">&nbsp;</td>
    <td height="33" colspan="2" valign="top">&nbsp;</td>
  </tr>
  <tr>
    <td width="216" height="32">&nbsp;</td>
    <td width="504"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="20%" height="25" align="center" class="nav"><a href="index.html">Home</a></td>
        <td width="20%" align="center" class="nav"><a href="About theeditplace.html">About us </a></td>
        <td width="20%" align="center" class="nav"><a href="Submitting work for English editing.html">Submit work </a></td>
        <td width="20%" align="center" class="nav"><a href="Pricing and payment.html">Pricing</a></td>
        <td width="20%" align="center" class="nav"><a href="contact.asp">Contact</a></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="19">&nbsp;</td>
    <td align="right" class="date">
      
<SCRIPT LANGUAGE="Javascript"><!--

var now = new Date();
var days = new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
var months = new Array('January','February','March','April','May','June','July','August','September','October','November','December');
var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
function fourdigits(number)      {
      return (number < 1000) ? number + 1900 : number;
                                                }
today =  days[now.getDay()] + ", " +
              months[now.getMonth()] + " " +
               date + ", " +
                (fourdigits(now.getYear())) ;

document.write("" +today+ "");
 
//--></SCRIPT>
      </td>
  </tr>
 
  <tr>
    <td height="473" colspan="2">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="30%" height="215"><img src="logo%20copy.jpg" width="214" height="72" /></td>
          <td width="70%" height="400" align="center" valign="middle" background="images/pen.jpg">
            <table width="415" height="282" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td width="415" height="282"><p align="left" class="bodytext"><strong>Contact Us</strong></p>
                  <p align="center" class="bodytext"><strong>Email</strong><br />
                  info@theeditplace.com</p>
                  <p align="center" class="bodytext"><strong>Phone</strong><br />
                    0871 218 0396  (within the UK)<br />
                    + 44 871 218 0396  (outside the UK)</p>
                  <p align="center" class="bodytext"><strong>Fax</strong><br />
                    0871 218 0397  (within the UK)<br />
                    + 44 871 218 0397  (outside the UK)</p>
                  <p align="center" class="bodytext"><strong>Post</strong><br />
                    16 Mount Batten, London N6 4HJ, England</p>
                  <p align="left" class="bodytext"><strong>Request Information</strong></p>
                   <form id="contact_form" method="post" action="contact.asp">
            <%
            If action <> "" Then
                'You can change this message to say whatever you want to say.
                Response.Write("<p style='color:#42487c; text-align:center;'>Thank you for your interest! Somebody will be in touch with you shortly.</p>")
            End If
           
            %>
           
            <table align="center">
            <tr>
                <td width="98" class="bodytext">Name:</td>
                <td width="161"><input type="text" name="name" /></td>
            </tr>
            <tr>
                <td class="bodytext">Surname:</td>
                <td><input type="text" name="surname" /></td>
            </tr>
            <tr>
                <td class="bodytext">Email Address:</td>
                <td><input type="text" name="email" /></td>
            </tr>
                  <tr>
                      <td valign="top"><span class="bodytext">Document Title</span>:</td
                        ><td><input type="text" name="title" /></td>
                  </tr>
            <tr>
                <td valign="top" class="bodytext">Request:</td>
                <td><textarea name="other" cols="15" rows="4"></textarea></td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="hidden" name="action" value="submitContactForm" />
                    <input type="submit" name="submit" value="Submit" />                </td>
            </tr>
           
            <!-- I am going to comment the document title out for right now, as we'll deal with file handling later. -->
            <!--
            <tr>
                <td>Document Title:</td>
                <td><input type="text" name="" /></td>
            </tr>
            -->
            </table>
            </form>
                  <p align="left" class="bodytext">&nbsp;</p>                  </td>
              </tr>
          </table>          </td>
        </tr>
        <tr>
          <td height="19">&nbsp;</td>
          <td height="19">&nbsp;</td>
        </tr>
        <tr>
          <td height="35">&nbsp;</td>
          <td height="35"><table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td align="center"><a href="Terms and Conditions of Service.doc" target="_blank" class="bodytext">Terms and Conditions </a><span class="style3"> <font face="Helvetica, Arial, sans-serif">|</font> </span><a href="Privacy Policy.doc" target="_blank" class="bodytext"> Privacy</a><span class="style3"> <font face="Helvetica, Arial, sans-serif">|</font> </span><a href="Accessibility.html" class="bodytext">Accessibility</a><span class="style3"> <font face="Helvetica, Arial, sans-serif">|</font> </span><a href="Site map for help navigating through this site.html" class="bodytext">Site Map</a></td>
              </tr>
          </table></td>
        </tr>
        <tr>
          <td height="19">&nbsp;</td>
          <td height="19" align="center" valign="middle" class="bodytext">&copy; theeditplace.com 2006</td>
        </tr>
    </table></td>
  </tr>
</table>
</body>
</html>


Thank you.
OK, everything below "ASP SCRIPT:" is your original code, and the code above it was provided by your ISP?

If so, 'rerun' your original code to determine the error that is preventing it from working ("my contact form suddenly started generating a 500 Internal Server Error message"). To rerun it, navigate to the page where this code resides. For example, if your original code is in a file named "email.asp", then go to:

http://yoursite/email.asp

and fill out the form and send it... Essentially, just do whatever you did when you received the 500 server error.

Once we know the error, then we can incorporate the new script into the old, if necessary. You may be able to repair your existing script however.
Hi,

The error message that came up was:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator to inform of the time the error occurred and of anything you might have done that may have caused the error.
More information about this error may be available in the server error log.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of SquareHead
SquareHead

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

My ISP has pointed my MX records back to their server and the problem seems to have disappeared - the contact form is working again. I will run some more tests on it over the next few hours to confirm this.
OK, glad you have it working. Do you mind telling me what hosting company you are using?
Not at all - if you tell me why you're asking!

Curious is all. I use several hosting companies and wanted to see if I yours was one of them. Not important really.