Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Sponsored Links

Discuss "self submitting contact form & GODADDY ???" in the ASP Development forum.

ASP Development - Learn coding practices and tips to get the best out of your Active Server Pages (ASP). The Classic ASP forum is for ASP/VBScript and ASP/JScript applications.


Reply « Previous Thread | Next Thread »  
 
LinkBack Thread Tools Display Modes
  #1  
Old August 21st, 2008, 08:32 PM
Barn Newbie
 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
jadamson is an unknown quantity at this point
Default self submitting contact form & GODADDY ???

This is my first post, so... HELLO & HOWDY

Now the good stuff...I am trying to get an asp contact form to work on a live site thats hosted at godaddy. I think its godaddy's basic windows package.

I contacted godaddy to make sure I was using the correct server name and they told me yes. Anyway, here is the error code...

CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/contact_us.asp, line 148

Here is line 148 in my code...
ObjSendMail.Send

I really have no idea, so any help would be wonderfull!
Reply With Quote
Sponsored Links
  #2  
Old August 21st, 2008, 08:43 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 818
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

See the following link on how to send mail form ASP pages on a GoDaddy server: How do I enable CDO.MESSAGE with MailEnable? - Help Center—Knowledge Base and FAQ

If you can't get the example in the link above to work, post the code exactly as you have it and any error messages that are generated.

Also, welcome to our community
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
Reply With Quote
  #3  
Old August 21st, 2008, 09:04 PM
Barn Newbie
 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
jadamson is an unknown quantity at this point
Default

I looked at that page on godaddy last night, not sure about it.

Here is my error message,
CDO.Message.1 error '80040213'
The transport failed to connect to the server.
/contact_us.asp, line 148


Here is the code,

Code:
<%@ LANGUAGE="VBSCRIPT" %>
<% option explicit %>
<% Response.Buffer = True %>

<%
'Declaring Variables
Dim smtpserver,youremail,yourpassword,ContactUs_Name,ContactUs_Email
Dim ContactUs_Subject,ContactUs_Body,Action,IsError
    
' Edit these 3 values accordingly
smtpserver = "smtpout.secureserver.net"
youremail = "XXXXX@lavoievenetianplaster.com"
yourpassword = "XXXXX"
    
' Grabbing variables from the form post
ContactUs_Name = Request("ContactUs_Name")
ContactUs_Email = Request("ContactUs_Email")
ContactUs_Subject = Request("ContactUs_Subject")
ContactUs_Body = Request("ContactUs_Body")
Action = Request("Action")
    
' Used to check that the email entered is in a valid format
Function IsValidEmail(Email)
    Dim ValidFlag,BadFlag,atCount,atLoop,SpecialFlag,UserName,DomainName,atChr,tAry1
    ValidFlag = False
        If (Email <> "") And (InStr(1, Email, "@") > 0) And (InStr(1, Email, ".") > 0) Then
            atCount = 0
            SpecialFlag = False
            For atLoop = 1 To Len(Email)
            atChr = Mid(Email, atLoop, 1)
                If atChr = "@" Then atCount = atCount + 1
                If (atChr >= Chr(32)) And (atChr <= Chr(44)) Then SpecialFlag = True
                If (atChr = Chr(47)) Or (atChr = Chr(96)) Or (atChr >= Chr(123)) Then SpecialFlag = True
                If (atChr >= Chr(58)) And (atChr <= Chr(63)) Then SpecialFlag = True
                If (atChr >= Chr(91)) And (atChr <= Chr(94)) Then SpecialFlag = True
            Next
            If (atCount = 1) And (SpecialFlag = False) Then
                BadFlag = False
                tAry1 = Split(Email, "@")
                UserName = tAry1(0)
                DomainName = tAry1(1)
            If (UserName = "") Or (DomainName = "") Then BadFlag = True
            If Mid(DomainName, 1, 1) = "." then BadFlag = True
            If Mid(DomainName, Len(DomainName), 1) = "." then BadFlag = True
                ValidFlag = True
            End If
        End If
        If BadFlag = True Then ValidFlag = False
        IsValidEmail = ValidFlag
End Function
%>

<html>

<head>
<title>Contact Us Form</title>
</head>

<body style="font-family: Arial; font-size: 12px">

<%
If Action = "SendEmail" Then
    
    ' Here we quickly check/validate the information entered
    ' These checks could easily be improved to look for more things
    If IsValidEmail(ContactUs_Email) = "False" Then
        IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a valid email address.</font><br>")
    End If
    
    If ContactUs_Name = "" Then
        IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a Name.</font><br>")
    End If
    
    If ContactUs_Subject = "" Then
    IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a Subject.</font><br>")
    End If
    
    If ContactUs_Body = "" Then
        IsError = "Yes"
        Response.Write("<font color=""red"">You did not enter a Body.</font><br>")
    End If
    
End If
    
' If there were no input errors and the action of the form is "SendEMail" we send the email off
If Action = "SendEmail" And IsError <> "Yes" Then
    
    Dim strBody
    
    ' Here we create a nice looking html body for the email
    strBody = strBody & "<font face=""Arial"">Contact Us Form submitted at " & Now() &  vbCrLf & "<br><br>"
    strBody = strBody & "From http://" & Request.ServerVariables("HTTP_HOST") &  vbCrLf & "<br>"
    strBody = strBody & "IP " & Request.ServerVariables("REMOTE_ADDR") & vbCrLf & "<br>"
    strBody = strBody & "Name" & " : " & " " & Replace(ContactUs_Name,vbCr,"<br>") & "<br>"
    strBody = strBody & "Email" & " : " & " " & Replace(ContactUs_Email,vbCr,"<br>") & "<br>"
    strBody = strBody & "Subject" & " : " & " " & Replace(ContactUs_Subject,vbCr,"<br>") & "<br>"
    strBody = strBody & "<br>" & Replace(ContactUs_Body,vbCr,"<br>") & "<br>"
    strBody = strBody & "</font>"
    
    Dim ObjSendMail
    Set ObjSendMail = CreateObject("CDO.Message") 
     
    'This section provides the configuration information for the remote SMTP server.
     
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
     
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = youremail
    ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = yourpassword
     
    ObjSendMail.Configuration.Fields.Update
     
    'End remote SMTP server configuration section==
     
    ObjSendMail.To = youremail
    ObjSendMail.Subject = ContactUs_Subject
    ObjSendMail.From = ContactUs_Email
     
    ' we are sending a html email.. simply switch the comments around to send a text email instead
    ObjSendMail.HTMLBody = strBody
    'ObjSendMail.TextBody = strBody
     
    ObjSendMail.Send
     
    Set ObjSendMail = Nothing 
    
' change the success messages below to say or do whatever you like
' you could do a response.redirect or offer a hyperlink somewhere.. etc etc
%>
<font size="2">Your message as seen below has been sent. Thank You !!
<br><br>
<font color="blue">
<% =Replace(ContactUs_Body,vbCr,"<br>") %>
</font>
</font>
<% Else %>

<form action="contact_us.asp" method="POST">
<input type="hidden" name="Action" value="SendEmail">
<font size="2">Contact Us:</font>
<br><br>
    <table border="0" cellspacing="1">
        <tr>
            <td valign="top">
                Name:
            </td>
            <td colspan="2">
                <input type="text" name="ContactUs_Name" size="35" value="<% =ContactUs_Name %>">
            </td>
        </tr>
        <tr>
            <td valign="top">
                Email:
            </td>
            <td colspan="2">
                <input type="text" name="ContactUs_Email" size="35" value="<% =ContactUs_Email %>">
            </td>
        </tr>
        <tr>
            <td valign="top">
                Subject:
            </td>
            <td colspan="2">
                <input type="text" name="ContactUs_Subject" value="<% =ContactUs_Subject %>" size="35">
            </td>
        </tr>
        <tr>
            <td valign="top">
                Message:
            </td>
            <td valign="top">
                <textarea rows="10" name="ContactUs_Body" cols="40"><% =ContactUs_Body %></textarea>
            </td>
        </tr>
        <tr>
            <td valign="top">&nbsp;
                
            </td>
            <td colspan="2">
                <input type="submit" value="Send Message">
            </td>
        </tr>
    </table>
</form>

<% End If %>



</body>

</html>

Last edited by jmurrayhead; August 21st, 2008 at 09:09 PM. Reason: added [code][/code] tags
Reply With Quote
  #4  
Old August 21st, 2008, 09:15 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 818
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

That doesn't look like the code they provided. Anyway, try the HTML example that I posted here: Sending Email with ASP and CDOSYS - Classic ASP

I would create a test page and see if you can get it to work with just a simple email. If it works, then plug in all of your custom error handling and such and see if it still works.
Reply With Quote
  #5  
Old August 21st, 2008, 09:35 PM
Barn Newbie
 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
jadamson is an unknown quantity at this point
Default

OK, that works! Now I just need to add the form and validation stuff! Its been about 3 years since I wrote a line of ASP

Thanks for your help.
Reply With Quote
  #6  
Old August 21st, 2008, 09:38 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 818
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by jadamson View Post
OK, that works! Now I just need to add the form and validation stuff! Its been about 3 years since I wrote a line of ASP

Thanks for your help.
You're welcome

It's been a little over a year since I've done anything with Classic ASP. I only do ASP.Net development these days
Reply With Quote
  #7  
Old August 22nd, 2008, 12:21 AM
Barn Newbie
 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 1
jadamson is an unknown quantity at this point
Default

OK, here is what I have so far. I need some help with the validation. The way its set up now it doesn't actually send me the email if any of the 3 fields are filled out. But if you skip a field and hit send it erases everything. I would like it to display some error messages and not clear every field if 1 thing is skipped...

Code:
<%
' Declare our variables:
Dim objCDO ' Our CDO object
Dim strTo ' Strings to hold our email fields
Dim strFrom
Dim strName
Dim strBody
 
'read in values from form 
strFrom = Request.Form("from")
strName = Request.Form("name")
strBody = Request.Form("body")
'set from email and subject
strTo = "myName@myDomain.com"
strSubject = "mySubject"
 
If strFrom = "" Or strName = "" Or strBody = "" Or Not IsValidEmail(strFrom) Then
    %>
    <form action="<%= Request.ServerVariables("URL") %>" METHOD="post">
        First/Last Name:<br />
<input type="text" name="name" size="30" /><br /><br />
 
Email:<br />
        <input type="text" name="From" size="30" /><br /><br /> 
 
Message:<br />
<textarea cols="40" rows="10" name="body"></textarea><br /><br />
 
<input type="submit" value="Send Mail!" />
    </form>
    <%
Else
    ' Send message
    Set objCDO = Server.CreateObject("CDO.Message")
    With objCDO
        .To = strTo
        .From = strFrom
        .Subject = strSubject
        .HtmlBody = "name = " & strName & " email = " & strFrom & " message = " & strBody 
        .Send
    End With
    Set objCDO = Nothing
 
    Response.Write "Thanks, we will reply to you at " & strFrom & "!"
End If
%>
 
<% 
Function IsValidEmail(strEmail)
    Dim bIsValid
    bIsValid = True
 
    If Len(strEmail) < 5 Then
        bIsValid = False
    Else
        If Instr(1, strEmail, " ") <> 0 Then
            bIsValid = False
        Else
            If InStr(1, strEmail, "@", 1) < 2 Then
                bIsValid = False
            Else
                If InStrRev(strEmail, ".") < InStr(1, strEmail, "@", 1) + 2 Then
                    bIsValid = False
                End If
            End If
        End If
    End If
 
    IsValidEmail = bIsValid
End Function
%>

Last edited by jmurrayhead; August 22nd, 2008 at 07:24 AM. Reason: added [code][/code] tags
Reply With Quote
  #8  
Old August 22nd, 2008, 07:26 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 818
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

That's an easy one

You can use the Request object to re-populate your fields. Take your form field "From", for example:

Code:
<input type="text" name="From" size="30" value="<%=Request.Form("From") %>" />
Also, please use the forum [code][/code] tags around your code. It makes it easier for us to read
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

Tags
cdo, form, mail

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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chooser Form sbenj69 Microsoft Access 6 August 14th, 2008 08:53 AM
filters on a form javier_83 Microsoft Access 4 July 28th, 2008 01:03 PM
Time Entry Form sbenj69 Microsoft Access 2 July 14th, 2008 02:11 PM


All times are GMT -4. The time now is 02:53 PM.



Content Relevant URLs by vBSEO 3.2.0