ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old April 23rd, 2008, 06:32 PM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 124 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 6 m 10 sec
Reputation Power: 1
Question ASPmail validation issue, please help

Hello;
I am reletivly new to writting asp. I am writting this aspmailer with form validation for my web site and right now I have 2 serious issues.

1. first problem is the validation is not validating phone numbers. When you submit the form, it comes back and tells you to enter a valid phone number even when you have it in the form feild.

2. The email won't send, it comes back with an error saying a connection to the server could not be reached and it is the proper server address.

What am I missing? I am fully stunped and don't know what code to add to this app. Can someone help me out? I am attaching my contact form code.

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


<%
Dim smtpserver,youremail,ContactUs_Name,ContactUs_Email
Dim ContactUs_Address,ContactUs_City,ContactUs_State,ContactUs_Phone,ContactUs_Zipcode
Dim ContactUs_Subject,ContactUs_Body,Action,IsError


smtpserver = "mail.mysite.com"
youremail = "me@mysite.com"


ContactUs_Name = Request("ContactUs_Name")
ContactUs_Address = Request("ContactUs_Address")
ContactUs_City = Request("ContactUs_City")
ContactUs_State = Request("ContactUs_State")
ContactUs_Zipcode = Request("ContactUs_Zipcode")
ContactUs_Phone = Request("ContactUs_Phone")
ContactUs_Email = Request("ContactUs_Email")
ContactUs_Subject = Request("ContactUs_Subject")
ContactUs_Body = Request("ContactUs_Body")
Action = Request("Action")


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
%>
<head>
</head>
<body>
<%
If Action = "SendEmail" Then

If ContactUs_Name = "" Then
IsError = "Yes"
Response.Write("<font color=""red"">You did not enter a Name.</font><br>")
End If

If IsValidEmail(ContactUs_Phone) = "False" Then
IsError = "Yes"
Response.Write("<font color=""red"">You did not enter a valid Phone Number.</font><br>")
End If

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

End If

If Action = "SendEmail" And IsError <> "Yes" Then

Dim strBody

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 & "Address" & " : " & " " & Replace(ContactUs_Address,vbCr,"<br>") & "<br>"
strBody = strBody & "City" & " : " & " " & Replace(ContactUs_City,vbCr,"<br>") & "<br>"
strBody = strBody & "State" & " : " & " " & Replace(ContactUs_State,vbCr,"<br>") & "<br>"
strBody = strBody & "Zipcode" & " : " & " " & Replace(ContactUs_Zipcode,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")


ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = smtpserver
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = youremail

ObjSendMail.Configuration.Fields.Update

ObjSendMail.To = youremail
ObjSendMail.Subject = ContactUs_Subject
ObjSendMail.From = ContactUs_Email


ObjSendMail.HTMLBody = strBody

ObjSendMail.Send

Set ObjSendMail = Nothing

%>
<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.asp" method="POST">
<input type="hidden" name="Action" value="SendEmail">
<input type="hidden" name="ContactUs_Subject" value="web contact">

<input name="ContactUs_Name" type="text" class="nd_Inputs" value="<% =ContactUs_Name %>">
<input name="ContactUs_Address" type="text" class="nd_Inputs" value="<% =ContactUs_Address %>">
<input name="ContactUs_City" type="text" class="nd_Inputs" value="<% =ContactUs_City %>">
<input name="ContactUs_State" type="text" class="NM_Inputs" value="<% =ContactUs_State %>">
<input name="ContactUs_Zipcode" type="text" class="nd_Inputs" value="<% =ContactUs_Zipcode %>">
<input name="ContactUs_Phone" type="text" class="nd_Inputs" value="<% =ContactUs_Phone %>">
<input name="ContactUs_Email" type="text" class="nd_Inputs" value="<% =ContactUs_Email %>">
<textarea name="ContactUs_Body" cols="25" rows="6" class="main_lgtexinput"><% =ContactUs_Body %></textarea>

<input type="submit" value="Send Message">
</form><% End If %>

I am fully stumped, I do know it is a lot of code needed to validate phone numbers, does anyone know what it is and how I would write it into my existing code? everything else seems to work properly.

Thank you!
Codemonger

Reply With Quote
  #2  
Old April 23rd, 2008, 09:37 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,713 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 57 m 59 sec
Reputation Power: 688
What have you attempted in debugging your problems? I have little interest in poring over all your code, you have to ask about one problem at a time with specific information like exact error messages, identify the line(s) of code causing errors, and describe how you have tried to cure the problem.
__________________
======
Doug G
======
"Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton

Reply With Quote
  #3  
Old April 24th, 2008, 06:53 AM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 124 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 6 m 10 sec
Reputation Power: 1
Quote:
Originally Posted by Doug G
What have you attempted in debugging your problems? I have little interest in poring over all your code, you have to ask about one problem at a time with specific information like exact error messages, identify the line(s) of code causing errors, and describe how you have tried to cure the problem.


OK, first issue is the phone number validation. that is these 2 lines of code:

If IsValidEmail(ContactUs_Phone) = "False" Then
IsError = "Yes"
Response.Write("<font color=""red"">You did not enter a valid Phone Number.</font><br>")
End If

and in the form:
<input name="ContactUs_Phone" type="text" class="nd_Inputs" value="<% =ContactUs_Phone %>">

I am not sure what I need to change, I think it is looking for the integer set up for a phone number. It doesn't throw an error, it just won't process the phone number even if it is entered into the code.

I will post the error for sending after I get this part fixed.

Thank you.

Codemonger.

Reply With Quote
  #4  
Old April 25th, 2008, 01:02 AM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,713 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 57 m 59 sec
Reputation Power: 688
Look at the IsValidEmail() function coding to figure out what kind of data will return true or false from that function.

Reply With Quote
  #5  
Old April 25th, 2008, 09:09 AM
codemonger codemonger is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2007
Posts: 124 codemonger User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 h 6 m 10 sec
Reputation Power: 1
Quote:
Originally Posted by Doug G
Look at the IsValidEmail() function coding to figure out what kind of data will return true or false from that function.


I figured that out now. That was a stupid mistake on my part. Right now this thing isn't sending email. I had it working last night and today it is throwing this error.

CDO.Message.1 error '80040212'

The transport lost its connection to the server.

/contact.asp, line 242


the code has changed a lot since yesturday, here is the mailer part of the code now:

EmailFrom = Trim(Request.Form("ContactUs_Email"))
EmailTo = "me@myweb.com"
Subject = "Web Site Form"

Body = Body & "From http://" & (Request.ServerVariables("HTTP_HOST")) & vbCrLf & "<br>"
Body = Body & "IP&nbsp;" & (Request.ServerVariables("REMOTE_ADDR")) & vbCrLf & "<br><br>"
Body = Body & "<b>Name:</b>&nbsp;" & Trim(Request.Form("ContactUs_Name")) & VbCrLf & "<br>"
Body = Body & "<b>Address:</b>&nbsp;" & Trim(Request.Form("ContactUs_Address")) & VbCrLf & "<br>"
Body = Body & "<b>City:</b>&nbsp;" & Trim(Request.Form("ContactUs_City")) & VbCrLf & "<br>"
Body = Body & "<b>State:</b>&nbsp;" & Trim(Request.Form("ContactUs_State")) & VbCrLf & "<br>"
Body = Body & "<b>Zipcode:</b>&nbsp;" & Trim(Request.Form("ContactUs_Zipcode")) & VbCrLf & "<br>"
Body = Body & "<b>Phone Number:</b>&nbsp;" & Trim(Request.Form("ContactUs_Phone")) & VbCrLf & "<br>"
Body = Body & "<b>Message:</b>&nbsp;" & Trim(Request.Form("ContactUs_Body")) & VbCrLf

Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.myweb.com"

.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10

.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.To = EmailTo
.From = EmailFrom
.Subject = Subject
.HTMLBody = Body
.Send <!--- this is throwing error now --->
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing

I am not sure why it isn't sending now. the part throwing the error is: .Send

Any ideas?

Codemonger

Reply With Quote
  #6  
Old April 25th, 2008, 10:10 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,713 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 23 h 57 m 59 sec
Reputation Power: 688
Most problems with asp and email are caused by problems outside of your asp code, such as network problems, misconfigured dns, spam filters, improper smtp server setup, and so forth. I don't use cdo but there are sample cdo asp codes at www.w3schools.com that may help, but you should verify all the rest of your email and server systems too.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > ASPmail validation issue, please help


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway