Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Contact Form, GoDaddy, Error on yahoo email account

Status
Not open for further replies.

ldtunited

Technical User
Jun 18, 2009
1
Good afternoon,

I am working to help a friend update their site and they have a website with a contact form hosted by godaddy. If a user fills out contact form with any email other than a *yahoo.com it works, if *.yahoo.com is used as the senders email it errors out to the FormErrorMessage. I can't figure out how to display the error from the hosted site (i.e. response.write etc) nor can we figure out what is causing the error.

Here is the code from form, THANK YOU in advance for anything you might be able to assist with.

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Contact.aspx.vb" Inherits="_Default" Title="Contact Us"%>
<asp:Content ID="Content01" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script runat="server">
Protected Sub SubmitForm_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsValid Then Exit Sub

Dim SendResults As String = "sales@site.com"
Dim SendResultsBCC As String = "myemail@verizon.net"
Dim smtpMailServer As String = "relay-hosting.secureserver.net"
Dim MailSubject As String = " Please contact us about your services."

Try
Dim txtQ As TextBox = Me.FormContent.FindControl("TextBoxQ")
If txtQ IsNot Nothing Then
Dim ans As String = ViewState("hf1")
If ans.ToLower <> txtQ.Text.ToLower Or ans.ToUpper <> txtQ.Text.ToUpper Then
Me.YourForm.ActiveViewIndex = 3
Exit Sub
End If
End If

Dim FromEmail As String = SendResults
Dim msgBody As StringBuilder = New StringBuilder()
Dim sendCC As Boolean = False


For Each c As Control In Me.FormContent.Controls
Select Case c.GetType.ToString
Case "System.Web.UI.WebControls.TextBox"
Dim txt As TextBox = CType(c, TextBox)
If txt.ID.ToLower <> "textboxq" Then
msgBody.Append(txt.ID & ": " & txt.Text & vbCrLf & vbCrLf)
End If
If txt.ID.ToLower = "email" Then
FromEmail = txt.Text
End If
If txt.ID.ToLower = "subject" Then
MailSubject = txt.Text
End If
Case "System.Web.UI.WebControls.CheckBox"
Dim chk As CheckBox = CType(c, CheckBox)
If chk.ID.ToLower = "checkboxcc" Then
If chk.Checked Then sendCC = True
Else
msgBody.Append(chk.ID & ": " & chk.Checked & vbCrLf & vbCrLf)
End If

Case "System.Web.UI.WebControls.RadioButton"
Dim rad As RadioButton = CType(c, RadioButton)
msgBody.Append(rad.ID & ": " & rad.Checked & vbCrLf & vbCrLf)
Case "System.Web.UI.WebControls.DropDownList"
Dim ddl As DropDownList = CType(c, DropDownList)
msgBody.Append(ddl.ID & ": " & ddl.SelectedValue & vbCrLf & vbCrLf)
End Select
Next
msgBody.AppendLine()

msgBody.Append("IP Address: " & Request.UserHostAddress & vbCrLf)
msgBody.Append("Server Date & Time: " & DateTime.Now.AddHours(2) & "CST" & vbCrLf & vbCrLf)

Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage()
myMessage.To.Add(SendResults)
myMessage.Bcc.Add(SendResultsBCC)
myMessage.From = New System.Net.Mail.MailAddress(FromEmail)
myMessage.Subject = MailSubject
myMessage.Body = msgBody.ToString
myMessage.IsBodyHtml = False
If sendCC Then myMessage.CC.Add(FromEmail)

Dim MailObj As New System.Net.Mail.SmtpClient(smtpMailServer)
MailObj.Send(myMessage)

Me.YourForm.ActiveViewIndex = 1
Catch
Me.YourForm.ActiveViewIndex = 2
End Try
End Sub
</script>
<!--CONTENT MAIN Page-->
<!-- start page -->
<div id="topnav">
<div id="tab"><a href="default.aspx">Home</a></div>

<div id="tab_emb"><a href="design.aspx">Screen Printing &amp; Embroidery</a></div>
<div id="tab_pi"><a href=" target="_blank">Promotional Items</a></div>
<div id="tab_web"><a href="web.aspx">Web</a></div>
<div id="tab_ai"><a href="aboutus.aspx">About Us</a></div>
<div id="tab_cu" class="selected"><a href="contact.aspx">Contact Us</a></div>
</div>
<div id="ocontainer">
<!-- start of content -->
<table style="width: 750px; background-color: white;" cellpadding="0" cellspacing="0" id="content">
<tr>
<td valign="top" style="width: 200px;">
<div id="leftnav">
<div style="margin-top:40px;margin-bottom:10px;text-align:center;width:150px;">
<img src="storeimages/clients.png" alt="" />
<%'Required to play flash movie via the web %>
<div id="flashcontent">
<%'If flash IS NOT installed show this %>
<ul style="vertical-align: middle; text-align: left;">
<li>Act Fast</li>
<li>Aerial Athletics</li>
<li>US Army</li>
<li>AT&amp;T</li>
<li>Anderson Ford</li>
<li>HCA</li>
<li>Cornerstone Church</li>
<li>Chevy</li>
<li>Rackspace</li>
<li>New Orleans Saints</li>
<li>SYSCO</li>
<li>Trane</li>
<li>USAA</li>
<li>YMCA</li>
</ul>
</div>
<%'If flash IS installed show this %>
<script type="text/javascript">
var so = new SWFObject("storeimages/logoflash.swf", "movie", "150", "60", "6", "#FFFFFF");
so.write("flashcontent");
</script>
</div>
</div>
</td>
<td valign="top" style="width: 550px;">
<table style="width: 100%" cellspacing="6">
<tr>
<td valign="top" style="width:295px;">
<h1>Contact Us </h1>
<p>Have a question? Call, e-mail, or use our convenient e-form below to contact us.
<br />
<span style="color: red;">* Indicates a Required Field</span></p>
<label id="errMsg">

</label>
</td>
<td rowspan="2" style="border:dotted 1px #DCDCDC;" valign="top">
<p style="margin:0;padding:10px; text-align: center; font-size: 10pt; color: #494949;">
<b>ACAG</b><br /> <br /> <br />
<a href="upload.aspx" target="_blank"> Upload Your File(s) Here</a>
</p>
</td>
</tr>
<tr>
<td valign="top">
<br />
<div id="whole">
<%--<form method='post' id='WebMail' action='WebMail.asp?Action=Save' onSubmit='return checkElements()'>--%>
<table border="0" width="295" cellspacing="2" cellpadding="0">
<tr>
<td>
<p >
<%--Start of contact us form--%>
<asp:MultiView ID="YourForm" runat="server" ActiveViewIndex="0">
<asp:View ID="FormContent" runat="server">

<%--<img src="images/contact_hdr.jpg" alt="" /><br /><br />--%>
<label for="Name">
<span style="color: red;">* Name:</span><br />
<asp:TextBox ID="Name" runat="server" Columns="35" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)"></asp:TextBox>
</label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="Name"
ErrorMessage="Please enter your name." SetFocusOnError="True" CssClass="ValidateMessage"
ForeColor="red">* Required</asp:RequiredFieldValidator>
<br />
<label for="Organization">
Organization:<br />
<asp:TextBox ID="Organization" runat="server" Columns="35" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label>
<br />
<label for="Email">
<span style="color: red;">* Email:</span><br />
<asp:TextBox ID="Email" runat="server" Columns="35" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Email"
Display="Dynamic" ErrorMessage="Please enter your email address." SetFocusOnError="True"
CssClass="ValidateMessage" ForeColor="red">* Required</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="Email"
ErrorMessage="Please enter a valid email address." SetFocusOnError="True" ValidationExpression="^([0-9a-zA-Z]([-\.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"
CssClass="ValidateMessage" ForeColor="red">* Please enter a valid email address.</asp:RegularExpressionValidator>
<br />
<label for="Service">
Desired Service:<br />
<asp:DropDownList ID="Service" runat="server">
<asp:ListItem Value="New Order">New Order</asp:ListItem>
<asp:ListItem Value="Order Update">Order Update</asp:ListItem>
<asp:ListItem Value="Upload Files">Upload Files</asp:ListItem>
<asp:ListItem Value="General Inquiry">General Inquiry</asp:ListItem>
<asp:ListItem Value="Question">Question</asp:ListItem>
<asp:ListItem Value="Suggestion">Suggestion</asp:ListItem>
<asp:ListItem Value="Problem">Problem</asp:ListItem>
<asp:ListItem Value="Testimonial">Testimonial</asp:ListItem>
<asp:ListItem Value="Other">Other</asp:ListItem>
</asp:DropDownList>
</label>
<br />
<label for="Product Number">
Product Number:<br />
<asp:TextBox ID="ProductNumber" runat="server" Columns="10" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label><br />
<label for="Quantity">
Quantity:<br />
<asp:TextBox ID="Quantity" runat="server" Columns="5" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label><br />
<label for="Color">
Color (design/shirt or cap):<br />
<asp:TextBox ID="Color" runat="server" Columns="10" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label><br />
<label for="DesignPlacement">
Design Placement (front, back, pocket etc):<br />
<asp:TextBox ID="DesignPlacement" runat="server" Columns="25" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label><br />
<label for="DueDate">
Due Date (mm/dd/yy):<br />
<%--Used to display calendar:<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>--%>
<asp:TextBox ID="DueDate" runat="server" Columns="6" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label><br />
<label for="Message">
Message:
<br />
<asp:TextBox ID="Message" runat="server" TextMode="MultiLine" Columns="35" Rows="3" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label>
<br />


<label for="Phone">
Phone Number (###-###-####):<br />
<asp:TextBox ID="Phone" runat="server" Columns="40" onFocus="CtrlOn(this)" onBlur="CtrlOff(this)">
</asp:TextBox>
</label>
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="Phone"
ErrorMessage="Please enter a valid U.S. phone number (including dashes)." SetFocusOnError="True"
ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}" CssClass="ValidateMessage"
ForeColor="red">* Please enter a valid U.S. phone number (including dashes).
</asp:RegularExpressionValidator>
Need to upload your file(s)? &nbsp;&nbsp; <a href="upload.aspx" target="_blank"> Click here!</a><br /><br />
<label for="Upload Files">
Did you upload any files?
<asp:DropDownList ID="UploadFiles" runat="server">
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>
</asp:DropDownList>
</label><br /><br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
ShowSummary="False" CssClass="ValidateMessage" ForeColor="red" />
<asp:Button ID="SubmitForm" runat="server" OnClick="SubmitForm_Click" Text="Submit Form" />
</asp:View>
<asp:View ID="FormConfirmationMessage" runat="server">
<br /><br /><br />
<b style="color: red;">Your message has been sent.</b> <br /><br />Thank you for contacting us,
you will hear from one of our associates within 24 hours.
</asp:View>
<asp:View ID="FormErrorMessage" runat="server">
<br /><br /><br />
Due to technical difficulty, your message may NOT have been sent.
again aga
</asp:View>
</asp:MultiView>
<%--End of contact us form--%>
</p>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- end of content -->
</div>
</asp:Content>
 
The main problem I can see is that you are programming the page like a classic ASP page. You should take advantage of the code-behind file for many reasons, the main one being able to easily debug any errors. Also, I am not sure why you are looping through controls on the page and casting them to set properties etc. This all can be done easily via the code behind file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top