Overthere
asked on
Urgent - Problem with ASp.net and Email
Hi folks,
I am receiving an server error on our hosted web site (shared GoDaddy.com) with a page that sends e-mail that is using ASp.Net smtp.
Sometimes it is fine and other times I receive the server below:
Server Error in '/' Application.
-------------------------- ---------- ---------- ---------- ---------- ---------- ----
At least one of the From or Sender fields is required, and neither was found.
I pass the "from" email address in a Session var and then put it into a var. I have displayed both the Session var and the variable, and the values are there and look fine (I previously in my validate rtn make sure it is not blank and has an @ in it)
I have tried putting qoutes around it and on both the "to" and "from" email addreses. Sometimes it works and sometimes it doesn't. Makes no sense to me.
I have even hardcode an email address in it and still may or may not, receive the error. You can see in the coding where I have commented out my attempts at wrapping in quotes. I REALLY need to use the "From" address from the input form. Right now I have the "to" and "from" address hardcoded. :(
Below is the coding from my page - I really need help with this...
You can test it at www.savinemallanimalrescue.org by clicking on the adoption application link.
Any help would be appericated.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Mail " %>
<% Session.Timeout="60" %>
<!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 runat="server">
<title>Confirmation </title>
<%
Dim vfullname As String = Session("FullName")
Dim vbodymsg As String = Session("vBodyMsg")
Dim vemail As String = Session("vEmail")
Dim vdog As String = Session("vdog")
Dim vserver As String = "relay-hosting.secureserve r.net"
Dim message As New MailMessage()
Dim vquotes As String = """"
'Dim vfrom = vquotes & vemail & vquotes
Dim vto = vquotes & "adoptdog@savinemallanimal rescue.org " & vquotes
' Response.Write(vfrom)
'Response.End()
message.Subject = "New Adoption Application for dog: " & vdog & " from " & vfullname
message.Body = vbodymsg
message.BodyFormat = MailFormat.Html
message.From = "adoptdog@savinemallanimal rescue.org "
'message.From = vfrom
message.To = "adoptdog@savinemallanimal rescue.org "
SmtpMail.SmtpServer = vserver
' Response.Write(vto & "<br/>")
' Response.End()
'get error message
'Try
SmtpMail.Send(message)
Response.Redirect("thankyo u.aspx")
'Catch ex As Exception
'Response.Write(ex)
'Response.Redirect("errorm sg.aspx")
'End Try
%>
<link href="css/savem.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#cccc99" >
<p></p>
<table align="center" width="500px">
<tr>
<td align="center"> Your information is being mailed
<br />
Please wait a moment.<br />
</td></tr>
</table>
</body>
</html>
I am receiving an server error on our hosted web site (shared GoDaddy.com) with a page that sends e-mail that is using ASp.Net smtp.
Sometimes it is fine and other times I receive the server below:
Server Error in '/' Application.
--------------------------
At least one of the From or Sender fields is required, and neither was found.
I pass the "from" email address in a Session var and then put it into a var. I have displayed both the Session var and the variable, and the values are there and look fine (I previously in my validate rtn make sure it is not blank and has an @ in it)
I have tried putting qoutes around it and on both the "to" and "from" email addreses. Sometimes it works and sometimes it doesn't. Makes no sense to me.
I have even hardcode an email address in it and still may or may not, receive the error. You can see in the coding where I have commented out my attempts at wrapping in quotes. I REALLY need to use the "From" address from the input form. Right now I have the "to" and "from" address hardcoded. :(
Below is the coding from my page - I really need help with this...
You can test it at www.savinemallanimalrescue.org by clicking on the adoption application link.
Any help would be appericated.
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Mail
<% Session.Timeout="60" %>
<!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 runat="server">
<title>Confirmation </title>
<%
Dim vfullname As String = Session("FullName")
Dim vbodymsg As String = Session("vBodyMsg")
Dim vemail As String = Session("vEmail")
Dim vdog As String = Session("vdog")
Dim vserver As String = "relay-hosting.secureserve
Dim message As New MailMessage()
Dim vquotes As String = """"
'Dim vfrom = vquotes & vemail & vquotes
Dim vto = vquotes & "adoptdog@savinemallanimal
' Response.Write(vfrom)
'Response.End()
message.Subject = "New Adoption Application for dog: " & vdog & " from " & vfullname
message.Body = vbodymsg
message.BodyFormat = MailFormat.Html
message.From = "adoptdog@savinemallanimal
'message.From = vfrom
message.To = "adoptdog@savinemallanimal
SmtpMail.SmtpServer = vserver
' Response.Write(vto & "<br/>")
' Response.End()
'get error message
'Try
SmtpMail.Send(message)
Response.Redirect("thankyo
'Catch ex As Exception
'Response.Write(ex)
'Response.Redirect("errorm
'End Try
%>
<link href="css/savem.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#cccc99" >
<p></p>
<table align="center" width="500px">
<tr>
<td align="center"> Your information is being mailed
<br />
Please wait a moment.<br />
</td></tr>
</table>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I check the input field for "from" e-mail address and if the length is <> 0 and it has an @, then I plop it into its Session var
Session(vEmail) = trim(txtEmail)
The odd thing is that when I display it in snippett of coding I intially provided in my question above, it is there and looks fine.
All of the Session vars are populated. Am I not forming the addresses correctly?
Session(vEmail) = trim(txtEmail)
The odd thing is that when I display it in snippett of coding I intially provided in my question above, it is there and looks fine.
All of the Session vars are populated. Am I not forming the addresses correctly?
So are you taking the user's email address and using that to send from?
Are you using the session variables because you are sending the mail from a different page to your form?
I usually just use the values direct from the text boxes with the built in validation control to ensure that the email address is ok.
and a compareValidator to make sure the email addresses are the same:
Are you using the session variables because you are sending the mail from a different page to your form?
I usually just use the values direct from the text boxes with the built in validation control to ensure that the email address is ok.
<asp:RegularExpressionValidator ID="regvalemail" runat="server"
ErrorMessage="Please enter an email address."
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ForeColor="Red" ControlToValidate="useremail">
</asp:RegularExpressionValidator>
and a compareValidator to make sure the email addresses are the same:
<asp:RegularExpressionValidator ID="regvalemail" runat="server"
ErrorMessage="Please enter an email address."
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ForeColor="Red" ControlToValidate="useremail">
</asp:RegularExpressionValidator>
<asp:CompareValidator ID="compEmail" runat="server" ErrorMessage="Please make sure the email addresses match." ControlToValidate="userEmail" ControlToCompare="userEmail2" ForeColor="Red"></asp:CompareValidator>
if you want to attach the full source for the email page i'll try it on my server.
Regards
Regards
ASKER
Yes, I am taking the users address (from) and using it in the email.
Here is the entire coding and please be sure to change the "to" address to something else so the rescue group doesn't become confused and holler at me over it :)
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Mail " %>
<% Session.Timeout="60" %>
<!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 runat="server">
<title>Confirmation </title>
<%
Dim vfullname As String = Session("FullName")
Dim vbodymsg As String = Session("vBodyMsg")
Dim vemail As String = Session("vEmail")
Dim vdog As String = Session("vdog")
Dim vserver As String = "relay-hosting.secureserve r.net"
Dim message As New MailMessage()
Dim vquotes As String = """"
Dim vfrom = vquotes & vemail & vquotes
Dim vto = vquotes & "adoptdog@savinemallanimal rescue.org " & vquotes
' Response.Write(vfrom)
'Response.End()
message.Subject = "New Adoption Application for dog: " & vdog & " from " & vfullname
message.Body = vbodymsg
message.BodyFormat = MailFormat.Html
message.From = "adoptdog@savinemallanimal rescue.org "
'message.From = vfrom
message.To = "adoptdog@savinemallanimal rescue.org "
SmtpMail.SmtpServer = vserver
' Response.Write(vto & "<br/>")
' Response.End()
'get error message
'Try
SmtpMail.Send(message)
Response.Redirect("thankyo u.aspx")
'Catch ex As Exception
'Response.Write(ex)
'Response.Redirect("errorm sg.aspx")
'End Try
%>
<link href="css/savem.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#cccc99" >
<p></p>
<p></p>
<p></p>
<p></p>
<table align="center" width="500px">
<tr>
<td align="center"> Your information is being mailed
<br />
Please wait a moment.<br />
</td></tr>
</table>
</body>
</html>
Here is the entire coding and please be sure to change the "to" address to something else so the rescue group doesn't become confused and holler at me over it :)
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Web.Mail
<% Session.Timeout="60" %>
<!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 runat="server">
<title>Confirmation </title>
<%
Dim vfullname As String = Session("FullName")
Dim vbodymsg As String = Session("vBodyMsg")
Dim vemail As String = Session("vEmail")
Dim vdog As String = Session("vdog")
Dim vserver As String = "relay-hosting.secureserve
Dim message As New MailMessage()
Dim vquotes As String = """"
Dim vfrom = vquotes & vemail & vquotes
Dim vto = vquotes & "adoptdog@savinemallanimal
' Response.Write(vfrom)
'Response.End()
message.Subject = "New Adoption Application for dog: " & vdog & " from " & vfullname
message.Body = vbodymsg
message.BodyFormat = MailFormat.Html
message.From = "adoptdog@savinemallanimal
'message.From = vfrom
message.To = "adoptdog@savinemallanimal
SmtpMail.SmtpServer = vserver
' Response.Write(vto & "<br/>")
' Response.End()
'get error message
'Try
SmtpMail.Send(message)
Response.Redirect("thankyo
'Catch ex As Exception
'Response.Write(ex)
'Response.Redirect("errorm
'End Try
%>
<link href="css/savem.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="#cccc99" >
<p></p>
<p></p>
<p></p>
<p></p>
<table align="center" width="500px">
<tr>
<td align="center"> Your information is being mailed
<br />
Please wait a moment.<br />
</td></tr>
</table>
</body>
</html>
I will change the address :)
Could you post the page that captures the email and stores it in the session var too?
Regards
Could you post the page that captures the email and stores it in the session var too?
Regards
ASKER
Sorry it took me so long to respond. Here is the coding from the page that catures the data:
Partial Class adoptfrm
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim vstring As String
Dim vmsg As String = ""
Dim title = "Errors!"
Dim verrswi As Integer = 0
Dim vfirst As String = ""
Dim vlast As String = ""
Dim vlabel As String = ""
Dim vbody As String = ""
Dim vstreet As String = ""
Dim vtest As String = ""
Dim vbrk As String = "<br/>"
Dim vfullname As String = ""
Dim vemail As String = ""
Dim vdog As String = ""
Dim vposition As Integer = 0
'===== Check Contact Information ===================
'check for first name
vstring = ""
vstring = Request.Form("txtFName")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = "* First Name *"
txtFName.BorderColor = Drawing.Color.DarkRed
txtFName.BorderWidth = "3"
Else
vfullname = Trim(vstring)
vbody = "Name: " & vstring
txtFName.BorderColor = Drawing.Color.Black
txtFName.BorderWidth = "1"
End If
vstring = ""
'check for last name
vstring = Request.Form("txtLName")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Last Name *"
txtLName.BorderColor = Drawing.Color.DarkRed
txtLName.BorderWidth = "3"
Else
vfullname = vfullname & " " & Trim(vstring)
vbody = vbody & " " & vstring & vbrk
txtLName.BorderColor = Drawing.Color.Black
txtLName.BorderWidth = "1"
End If
'get age
vstring = Request.Form("txtAge")
vbody = vbody & "Age: " & Trim(vstring) & vbrk
'check for street address
vstring = ""
vstring = Request.Form("txtStreet")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * Address *"
txtStreet.BorderColor = Drawing.Color.DarkRed
txtStreet.BorderWidth = "3"
Else
vbody = vbody & "Address: " & Trim(vstring) & vbrk
txtStreet.BorderColor = Drawing.Color.Black
txtStreet.BorderWidth = "1"
End If
vstring = ""
'check for city
vstring = Request.Form("txtCity")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* City *"
txtCity.BorderColor = Drawing.Color.DarkRed
txtCity.BorderWidth = "3"
Else
vbody = vbody & "City: " & Trim(vstring) & vbrk
txtCity.BorderColor = Drawing.Color.Black
txtCity.BorderWidth = "1"
End If
'check for state
vstring = ""
vstring = Request.Form("txtState")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * State *"
txtState.BorderColor = Drawing.Color.DarkRed
txtState.BorderWidth = "3"
Else
vbody = vbody & "State: " & Trim(vstring) & vbrk
txtState.BorderColor = Drawing.Color.Black
txtState.BorderWidth = "1"
End If
'check for zipcode
vstring = ""
vstring = Request.Form("txtZip")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * Zipcode *"
txtZip.BorderColor = Drawing.Color.DarkRed
txtZip.BorderWidth = "3"
Else
vbody = vbody & "Zipcode: " & Trim(vstring) & vbrk
txtZip.BorderColor = Drawing.Color.Black
txtZip.BorderWidth = "1"
End If
'check for email
vstring = ""
vstring = Request.Form("txtMail")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* E-mail Address *"
txtMail.BorderColor = Drawing.Color.DarkRed
txtMail.BorderWidth = "3"
Else
vbody = vbody & "E-Mail Address: " & Trim(vstring) & vbrk
txtMail.BorderColor = Drawing.Color.Black
txtMail.BorderWidth = "1"
vemail = vstring
End If
'is it a valid email address?
vstring = ""
vstring = Request.Form("txtMail")
vposition = InStr(1, vstring, "@")
If vposition = 0 Then
verrswi = verrswi + 1
vmsg = vmsg & "* Invalid E-mail Address *"
txtMail.BorderColor = Drawing.Color.DarkRed
txtMail.BorderWidth = "3"
Else
vbody = vbody & "E-Mail Address: " & Trim(vstring) & vbrk
txtMail.BorderColor = Drawing.Color.Black
txtMail.BorderWidth = "1"
vemail = vstring
End If
'check for home telephone
vstring = Request.Form("txtHomeNbr")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Home Telephone *"
txtHomeNbr.BorderColor = Drawing.Color.DarkRed
txtHomeNbr.BorderWidth = "3"
Else
vbody = vbody & "Home Phone: " & Trim(vstring) & vbrk
txtHomeNbr.BorderColor = Drawing.Color.Black
txtHomeNbr.BorderWidth = "1"
End If
'check for work telephone
vstring = Request.Form("txtWorkNbr")
vbody = vbody & "Work Phone: " & Trim(vstring) & vbrk
'check for cell telephone
vstring = Request.Form("txtCell")
vbody = vbody & "Cell Phone: " & Trim(vstring) & vbrk
'check for dog interested in
vstring = Request.Form("txtDog")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Specific Dog Interested in *"
txtDog.BorderColor = Drawing.Color.DarkRed
txtDog.BorderWidth = "3"
Else
vdog = Trim(vstring)
vbody = vbody & "Specific Dog Interested in: " & vstring & vbrk
txtDog.BorderColor = Drawing.Color.Black
txtDog.BorderWidth = "1"
End If
'==================== Check for References ========================== ==
'check for vet name
vstring = ""
vstring = Request.Form("txtVet")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Vet Required *"
txtVet.BorderColor = Drawing.Color.DarkRed
txtVet.BorderWidth = "3"
Else
vbody = vbody & "Vet/Alternate Reference: " & Trim(vstring) & vbrk
txtVet.BorderColor = Drawing.Color.Black
txtVet.BorderWidth = "1"
End If
'check for vet address
vstring = ""
vstring = Request.Form("txtVetStreet ")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Vet's Address Required *"
txtVetStreet.BorderColor = Drawing.Color.DarkRed
txtVetStreet.BorderWidth = "3"
Else
vbody = vbody & "Vet/Alternate Address: " & Trim(vstring) & vbrk
txtVetStreet.BorderColor = Drawing.Color.Black
txtVetStreet.BorderWidth = "1"
End If
'check for vet telephone
vstring = ""
vstring = Request.Form("txtVetPhone" )
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Vet's Telephone *"
txtVetPhone.BorderColor = Drawing.Color.DarkRed
txtVetPhone.BorderWidth = "3"
Else
vbody = vbody & "Vet/Alternate Telephone: " & Trim(vstring) & vbrk
txtVetPhone.BorderColor = Drawing.Color.Black
txtVetPhone.BorderWidth = "1"
End If
'=============== Check Household Informtion ========================== =======
' get Nbr of adults
vstring = Request.Form("txtNbrAdults ")
vbody = vbody & "Nbr of Adults: " & Trim(vstring) & vbrk
'get nbr of kids
vstring = Request.Form("txtNbrKids")
vbody = vbody & "Nbr of Children: " & Trim(vstring) & vbrk
'get list of kids
vstring = Request.Form("txtKidsNames ")
vbody = vbody & "List of Children: " & Trim(vstring) & vbrk
'get vistors
vstring = Request.Form("txtVistors")
vbody = vbody & "List of Vistors: " & Trim(vstring) & vbrk
'get other dogs
vstring = RadOtherDogs.SelectedValue ()
vbody = vbody & "Do you have other dogs? " & Trim(vstring) & vbrk
'get nbr of other dogs
vstring = Request.Form("txtNbrOtherD ogs")
vbody = vbody & "Number of other dogs: " & Trim(vstring) & vbrk
'get spayed/neutered
vstring = RadFixed.SelectedValue()
vbody = vbody & "Are they spayed/neutered? " & Trim(vstring) & vbrk
'get breeds
vstring = Request.Form("txtBreeds")
vbody = vbody & "List breed sex and age of each dog: " & Trim(vstring) & vbrk
'get nbr of dogs previously owned
vstring = Request.Form("txtNbrOwn")
vbody = vbody & "How many dogs have you owned in the last five years? " & Trim(vstring) & vbrk
'get still own them
vstring = RadStillOwn.SelectedValue( )
vbody = vbody & "Do you still own them? " & Trim(vstring) & vbrk
'get disposition of dogs previously owned
vstring = Request.Form("txtGone")
vbody = vbody & "If not what happened to the dog? " & Trim(vstring) & vbrk
'get own cats
vstring = RadCats.SelectedValue()
vbody = vbody & "do you own cats? " & Trim(vstring) & vbrk
'get nbr of cats
vstring = Request.Form("txtNbrCats")
vbody = vbody & "How many cats? " & Trim(vstring) & vbrk
'get other animals
vstring = RadAnimals.SelectedValue()
vbody = vbody & "Do you own other animals? " & Trim(vstring) & vbrk
' get other animals description
vstring = Request.Form("txtAnimalsDe s")
vbody = vbody & "Please describe your other animals: " & Trim(vstring) & vbrk
'get livestock
vstring = RadLiveStock.SelectedValue ()
vbody = vbody & "Do you own livestock? " & Trim(vstring) & vbrk
' get livestock description
vstring = Request.Form("txtLiveStock ")
vbody = vbody & "Please describe your livestock: " & Trim(vstring) & vbrk
' get owning home
vstring = RadHome.SelectedValue()
vbody = vbody & "Do you pwn your own home? " & Trim(vstring) & vbrk
'get landlord permission
vstring = RadLand.SelectedValue()
vbody = vbody & "If you rent do you have the landlords permission to keep a dog?? " & Trim(vstring) & vbrk
' get landlord information
vstring = Request.Form("txtLandName" )
vbody = vbody & "Your lanlords information: " & Trim(vstring) & vbrk
' get type of resident
vstring = lstResidence.SelectedValue ()
vbody = vbody & "Type of residence: " & Trim(vstring) & vbrk
' get type of other resident
vstring = Request.Form("txtOtherHome ")
vbody = vbody & "Type of other residence: " & Trim(vstring) & vbrk
'get nbr year residence
vstring = Request.Form("txtYears")
vbody = vbody & "Number of years at residence: " & Trim(vstring) & vbrk
'get if moving soon
vstring = RadMove.SelectedValue()
vbody = vbody & "Are you planning to move soon? " & Trim(vstring) & vbrk
'get do they have a fence
vstring = RadFence.SelectedValue()
vbody = vbody & "Do you have a fence? " & Trim(vstring) & vbrk
'get type of fence
vstring = lstFenceMat.SelectedValue( )
vbody = vbody & "Type of fencing: " & Trim(vstring) & vbrk
'get other fence description
vstring = Request.Form("txtOtherFenc e")
vbody = vbody & "Type of other fencing: " & Trim(vstring) & vbrk
'get enclosed fence
vstring = RadClosed.SelectedValue()
vbody = vbody & "Does the fencing completely enclose the yard? " & Trim(vstring) & vbrk
'get kennel
vstring = RadKennel.SelectedValue()
vbody = vbody & "Do you have a kennel run? " & Trim(vstring) & vbrk
'get kennel size
vstring = Request.Form("txtKenSize")
vbody = vbody & "Size of kennel run: " & Trim(vstring) & vbrk
' get own dog before
vstring = RadPrevOwn.SelectedValue()
vbody = vbody & "Have you owned a dog before? " & Trim(vstring) & vbrk
'get where dog will be during day
vstring = lstDay.SelectedValue()
vbody = vbody & "Where will the dog spend the day? " & Trim(vstring) & vbrk
'get if other day
vstring = Request.Form("txtDayOther" )
vbody = vbody & "If other please describe: " & Trim(vstring) & vbrk
'get where dog will be during night
vstring = lstNight.SelectedValue()
vbody = vbody & "Where will the dog spend the night? " & Trim(vstring) & vbrk
'get if other night
vstring = Request.Form("txtNightOthe r")
vbody = vbody & "If other please describe: " & Trim(vstring) & vbrk
'get how much time alone
vstring = Request.Form("txtAlone")
vbody = vbody & "How many hours a day on the average will the dog spent alone? " & Trim(vstring) & vbrk
'get how much time in crate
vstring = Request.Form("txtCrate")
vbody = vbody & "How many hours a day on the average will the dog spent in a crate? " & Trim(vstring) & vbrk
'get potty training
vstring = Request.Form("txtPotty")
vbody = vbody & "If applying for puppy hpw will you handle potty breaks during working hours or prolonged absences? " & Trim(vstring) & vbrk
'get willing to train
vstring = RadTrain.SelectedValue()
vbody = vbody & "Will you commit to taking your dog or puppy to obedeince school? " & Trim(vstring) & vbrk
'get signature
vstring = ""
vstring = Request.Form("txtSign")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * Signature *"
txtSign.BorderColor = Drawing.Color.DarkRed
txtSign.BorderWidth = "3"
Else
vbody = vbody & "Signature: " & Trim(vstring) & vbrk
txtSign.BorderColor = Drawing.Color.Black
txtSign.BorderWidth = "1"
End If
'get date
vstring = ""
vstring = Request.Form("txtDate")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Date Signed *"
txtDate.BorderColor = Drawing.Color.DarkRed
txtDate.BorderWidth = "3"
Else
vbody = vbody & "Date: " & Trim(vstring) & vbrk
txtDate.BorderColor = Drawing.Color.Black
txtDate.BorderWidth = "1"
End If
'===== Are their errors? ========================== ========
If verrswi <> 0 Then
lblErrMsg.Text = "ERRORS! THE FOLLOWING INFORMATION IS REQUIRED AND IS MISSING: <br/><font color=black> " & vmsg & "</font><br/>"
lblErrMsg.Visible = True
Else
lblErrMsg.Visible = False
Session("FullName") = vfullname
Session("vBodyMsg") = vbody
Session("vEmail") = vemail
Session("vDog") = vdog
Response.Redirect("confirm .aspx")
End If
End Sub
Protected Sub Cancel_Click(sender As Object, e As System.EventArgs) Handles Cancel.Click
Response.Redirect("http://www.savinemallanimalrescue.org/index.html")
End Sub
End Class
Partial Class adoptfrm
Inherits System.Web.UI.Page
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Dim vstring As String
Dim vmsg As String = ""
Dim title = "Errors!"
Dim verrswi As Integer = 0
Dim vfirst As String = ""
Dim vlast As String = ""
Dim vlabel As String = ""
Dim vbody As String = ""
Dim vstreet As String = ""
Dim vtest As String = ""
Dim vbrk As String = "<br/>"
Dim vfullname As String = ""
Dim vemail As String = ""
Dim vdog As String = ""
Dim vposition As Integer = 0
'===== Check Contact Information ===================
'check for first name
vstring = ""
vstring = Request.Form("txtFName")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = "* First Name *"
txtFName.BorderColor = Drawing.Color.DarkRed
txtFName.BorderWidth = "3"
Else
vfullname = Trim(vstring)
vbody = "Name: " & vstring
txtFName.BorderColor = Drawing.Color.Black
txtFName.BorderWidth = "1"
End If
vstring = ""
'check for last name
vstring = Request.Form("txtLName")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Last Name *"
txtLName.BorderColor = Drawing.Color.DarkRed
txtLName.BorderWidth = "3"
Else
vfullname = vfullname & " " & Trim(vstring)
vbody = vbody & " " & vstring & vbrk
txtLName.BorderColor = Drawing.Color.Black
txtLName.BorderWidth = "1"
End If
'get age
vstring = Request.Form("txtAge")
vbody = vbody & "Age: " & Trim(vstring) & vbrk
'check for street address
vstring = ""
vstring = Request.Form("txtStreet")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * Address *"
txtStreet.BorderColor = Drawing.Color.DarkRed
txtStreet.BorderWidth = "3"
Else
vbody = vbody & "Address: " & Trim(vstring) & vbrk
txtStreet.BorderColor = Drawing.Color.Black
txtStreet.BorderWidth = "1"
End If
vstring = ""
'check for city
vstring = Request.Form("txtCity")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* City *"
txtCity.BorderColor = Drawing.Color.DarkRed
txtCity.BorderWidth = "3"
Else
vbody = vbody & "City: " & Trim(vstring) & vbrk
txtCity.BorderColor = Drawing.Color.Black
txtCity.BorderWidth = "1"
End If
'check for state
vstring = ""
vstring = Request.Form("txtState")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * State *"
txtState.BorderColor = Drawing.Color.DarkRed
txtState.BorderWidth = "3"
Else
vbody = vbody & "State: " & Trim(vstring) & vbrk
txtState.BorderColor = Drawing.Color.Black
txtState.BorderWidth = "1"
End If
'check for zipcode
vstring = ""
vstring = Request.Form("txtZip")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * Zipcode *"
txtZip.BorderColor = Drawing.Color.DarkRed
txtZip.BorderWidth = "3"
Else
vbody = vbody & "Zipcode: " & Trim(vstring) & vbrk
txtZip.BorderColor = Drawing.Color.Black
txtZip.BorderWidth = "1"
End If
'check for email
vstring = ""
vstring = Request.Form("txtMail")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* E-mail Address *"
txtMail.BorderColor = Drawing.Color.DarkRed
txtMail.BorderWidth = "3"
Else
vbody = vbody & "E-Mail Address: " & Trim(vstring) & vbrk
txtMail.BorderColor = Drawing.Color.Black
txtMail.BorderWidth = "1"
vemail = vstring
End If
'is it a valid email address?
vstring = ""
vstring = Request.Form("txtMail")
vposition = InStr(1, vstring, "@")
If vposition = 0 Then
verrswi = verrswi + 1
vmsg = vmsg & "* Invalid E-mail Address *"
txtMail.BorderColor = Drawing.Color.DarkRed
txtMail.BorderWidth = "3"
Else
vbody = vbody & "E-Mail Address: " & Trim(vstring) & vbrk
txtMail.BorderColor = Drawing.Color.Black
txtMail.BorderWidth = "1"
vemail = vstring
End If
'check for home telephone
vstring = Request.Form("txtHomeNbr")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Home Telephone *"
txtHomeNbr.BorderColor = Drawing.Color.DarkRed
txtHomeNbr.BorderWidth = "3"
Else
vbody = vbody & "Home Phone: " & Trim(vstring) & vbrk
txtHomeNbr.BorderColor = Drawing.Color.Black
txtHomeNbr.BorderWidth = "1"
End If
'check for work telephone
vstring = Request.Form("txtWorkNbr")
vbody = vbody & "Work Phone: " & Trim(vstring) & vbrk
'check for cell telephone
vstring = Request.Form("txtCell")
vbody = vbody & "Cell Phone: " & Trim(vstring) & vbrk
'check for dog interested in
vstring = Request.Form("txtDog")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Specific Dog Interested in *"
txtDog.BorderColor = Drawing.Color.DarkRed
txtDog.BorderWidth = "3"
Else
vdog = Trim(vstring)
vbody = vbody & "Specific Dog Interested in: " & vstring & vbrk
txtDog.BorderColor = Drawing.Color.Black
txtDog.BorderWidth = "1"
End If
'==================== Check for References ==========================
'check for vet name
vstring = ""
vstring = Request.Form("txtVet")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Vet Required *"
txtVet.BorderColor = Drawing.Color.DarkRed
txtVet.BorderWidth = "3"
Else
vbody = vbody & "Vet/Alternate Reference: " & Trim(vstring) & vbrk
txtVet.BorderColor = Drawing.Color.Black
txtVet.BorderWidth = "1"
End If
'check for vet address
vstring = ""
vstring = Request.Form("txtVetStreet
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Vet's Address Required *"
txtVetStreet.BorderColor = Drawing.Color.DarkRed
txtVetStreet.BorderWidth = "3"
Else
vbody = vbody & "Vet/Alternate Address: " & Trim(vstring) & vbrk
txtVetStreet.BorderColor = Drawing.Color.Black
txtVetStreet.BorderWidth = "1"
End If
'check for vet telephone
vstring = ""
vstring = Request.Form("txtVetPhone"
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Vet's Telephone *"
txtVetPhone.BorderColor = Drawing.Color.DarkRed
txtVetPhone.BorderWidth = "3"
Else
vbody = vbody & "Vet/Alternate Telephone: " & Trim(vstring) & vbrk
txtVetPhone.BorderColor = Drawing.Color.Black
txtVetPhone.BorderWidth = "1"
End If
'=============== Check Household Informtion ==========================
' get Nbr of adults
vstring = Request.Form("txtNbrAdults
vbody = vbody & "Nbr of Adults: " & Trim(vstring) & vbrk
'get nbr of kids
vstring = Request.Form("txtNbrKids")
vbody = vbody & "Nbr of Children: " & Trim(vstring) & vbrk
'get list of kids
vstring = Request.Form("txtKidsNames
vbody = vbody & "List of Children: " & Trim(vstring) & vbrk
'get vistors
vstring = Request.Form("txtVistors")
vbody = vbody & "List of Vistors: " & Trim(vstring) & vbrk
'get other dogs
vstring = RadOtherDogs.SelectedValue
vbody = vbody & "Do you have other dogs? " & Trim(vstring) & vbrk
'get nbr of other dogs
vstring = Request.Form("txtNbrOtherD
vbody = vbody & "Number of other dogs: " & Trim(vstring) & vbrk
'get spayed/neutered
vstring = RadFixed.SelectedValue()
vbody = vbody & "Are they spayed/neutered? " & Trim(vstring) & vbrk
'get breeds
vstring = Request.Form("txtBreeds")
vbody = vbody & "List breed sex and age of each dog: " & Trim(vstring) & vbrk
'get nbr of dogs previously owned
vstring = Request.Form("txtNbrOwn")
vbody = vbody & "How many dogs have you owned in the last five years? " & Trim(vstring) & vbrk
'get still own them
vstring = RadStillOwn.SelectedValue(
vbody = vbody & "Do you still own them? " & Trim(vstring) & vbrk
'get disposition of dogs previously owned
vstring = Request.Form("txtGone")
vbody = vbody & "If not what happened to the dog? " & Trim(vstring) & vbrk
'get own cats
vstring = RadCats.SelectedValue()
vbody = vbody & "do you own cats? " & Trim(vstring) & vbrk
'get nbr of cats
vstring = Request.Form("txtNbrCats")
vbody = vbody & "How many cats? " & Trim(vstring) & vbrk
'get other animals
vstring = RadAnimals.SelectedValue()
vbody = vbody & "Do you own other animals? " & Trim(vstring) & vbrk
' get other animals description
vstring = Request.Form("txtAnimalsDe
vbody = vbody & "Please describe your other animals: " & Trim(vstring) & vbrk
'get livestock
vstring = RadLiveStock.SelectedValue
vbody = vbody & "Do you own livestock? " & Trim(vstring) & vbrk
' get livestock description
vstring = Request.Form("txtLiveStock
vbody = vbody & "Please describe your livestock: " & Trim(vstring) & vbrk
' get owning home
vstring = RadHome.SelectedValue()
vbody = vbody & "Do you pwn your own home? " & Trim(vstring) & vbrk
'get landlord permission
vstring = RadLand.SelectedValue()
vbody = vbody & "If you rent do you have the landlords permission to keep a dog?? " & Trim(vstring) & vbrk
' get landlord information
vstring = Request.Form("txtLandName"
vbody = vbody & "Your lanlords information: " & Trim(vstring) & vbrk
' get type of resident
vstring = lstResidence.SelectedValue
vbody = vbody & "Type of residence: " & Trim(vstring) & vbrk
' get type of other resident
vstring = Request.Form("txtOtherHome
vbody = vbody & "Type of other residence: " & Trim(vstring) & vbrk
'get nbr year residence
vstring = Request.Form("txtYears")
vbody = vbody & "Number of years at residence: " & Trim(vstring) & vbrk
'get if moving soon
vstring = RadMove.SelectedValue()
vbody = vbody & "Are you planning to move soon? " & Trim(vstring) & vbrk
'get do they have a fence
vstring = RadFence.SelectedValue()
vbody = vbody & "Do you have a fence? " & Trim(vstring) & vbrk
'get type of fence
vstring = lstFenceMat.SelectedValue(
vbody = vbody & "Type of fencing: " & Trim(vstring) & vbrk
'get other fence description
vstring = Request.Form("txtOtherFenc
vbody = vbody & "Type of other fencing: " & Trim(vstring) & vbrk
'get enclosed fence
vstring = RadClosed.SelectedValue()
vbody = vbody & "Does the fencing completely enclose the yard? " & Trim(vstring) & vbrk
'get kennel
vstring = RadKennel.SelectedValue()
vbody = vbody & "Do you have a kennel run? " & Trim(vstring) & vbrk
'get kennel size
vstring = Request.Form("txtKenSize")
vbody = vbody & "Size of kennel run: " & Trim(vstring) & vbrk
' get own dog before
vstring = RadPrevOwn.SelectedValue()
vbody = vbody & "Have you owned a dog before? " & Trim(vstring) & vbrk
'get where dog will be during day
vstring = lstDay.SelectedValue()
vbody = vbody & "Where will the dog spend the day? " & Trim(vstring) & vbrk
'get if other day
vstring = Request.Form("txtDayOther"
vbody = vbody & "If other please describe: " & Trim(vstring) & vbrk
'get where dog will be during night
vstring = lstNight.SelectedValue()
vbody = vbody & "Where will the dog spend the night? " & Trim(vstring) & vbrk
'get if other night
vstring = Request.Form("txtNightOthe
vbody = vbody & "If other please describe: " & Trim(vstring) & vbrk
'get how much time alone
vstring = Request.Form("txtAlone")
vbody = vbody & "How many hours a day on the average will the dog spent alone? " & Trim(vstring) & vbrk
'get how much time in crate
vstring = Request.Form("txtCrate")
vbody = vbody & "How many hours a day on the average will the dog spent in a crate? " & Trim(vstring) & vbrk
'get potty training
vstring = Request.Form("txtPotty")
vbody = vbody & "If applying for puppy hpw will you handle potty breaks during working hours or prolonged absences? " & Trim(vstring) & vbrk
'get willing to train
vstring = RadTrain.SelectedValue()
vbody = vbody & "Will you commit to taking your dog or puppy to obedeince school? " & Trim(vstring) & vbrk
'get signature
vstring = ""
vstring = Request.Form("txtSign")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & " * Signature *"
txtSign.BorderColor = Drawing.Color.DarkRed
txtSign.BorderWidth = "3"
Else
vbody = vbody & "Signature: " & Trim(vstring) & vbrk
txtSign.BorderColor = Drawing.Color.Black
txtSign.BorderWidth = "1"
End If
'get date
vstring = ""
vstring = Request.Form("txtDate")
If vstring = "" Then
verrswi = verrswi + 1
vmsg = vmsg & "* Date Signed *"
txtDate.BorderColor = Drawing.Color.DarkRed
txtDate.BorderWidth = "3"
Else
vbody = vbody & "Date: " & Trim(vstring) & vbrk
txtDate.BorderColor = Drawing.Color.Black
txtDate.BorderWidth = "1"
End If
'===== Are their errors? ==========================
If verrswi <> 0 Then
lblErrMsg.Text = "ERRORS! THE FOLLOWING INFORMATION IS REQUIRED AND IS MISSING: <br/><font color=black> " & vmsg & "</font><br/>"
lblErrMsg.Visible = True
Else
lblErrMsg.Visible = False
Session("FullName") = vfullname
Session("vBodyMsg") = vbody
Session("vEmail") = vemail
Session("vDog") = vdog
Response.Redirect("confirm
End If
End Sub
Protected Sub Cancel_Click(sender As Object, e As System.EventArgs) Handles Cancel.Click
Response.Redirect("http://www.savinemallanimalrescue.org/index.html")
End Sub
End Class
no problem, what's the setup of the form and email pages?
are the on the same server? is fs23.formsite.com seperate to your main site?
Regards
are the on the same server? is fs23.formsite.com seperate to your main site?
Regards
ASKER
I awarded the points because even though this issue isn't really resolved, they are staying with the formsite form..sigh
I just wish I knew why my Session vars did what they did....
I just wish I knew why my Session vars did what they did....
:( I couldn't see anything obvious, I guess you have to go through all that server side validation because they are using form site?
Nice project to work on by the way :)
Nice project to work on by the way :)
In the <%@ Page Language="VB" validateRequest="false" %>
More detail
http://forums.asp.net/p/1211047/2134215.aspx#2134215