Forum Moderators: open
<% @Import Namespace="System.Web.Mail" %>
<script language="vb" runat="server">
Sub btnSubmit_Click(sender as Object, e as EventArgs)
Dim strEmpty as string = "n/a"
Dim strCustomer as string = "Customer_Get_A_Quote"
If txtAddress.Text.Length < 1
txtAddress.Text = strEmpty
End If
If txtCity.Text.Length < 1
txtCity.Text = strEmpty
End If
If txtState.Text.Length < 1
txtState.Text = strEmpty
End If
If txtZip.Text.Length < 1
txtZip.Text = strEmpty
End If
If txtContact2.Text.Length < 1
txtContact2.Text = strEmpty
End If
If txtEmail.Text.Length < 1
txtEmail.Text = strCustomer
End If
If txtOption.Text.Length < 1
txtOption.Text = strEmpty
End If
'Create an instance of the MailMessage class
Dim objMM as New MailMessage()
'Set the properties - send the email to the person who filled out the
'feedback form.
objMM.To = ""
'objMM.To = ""
objMM.From = txtEmail.Text
'objMM.From = ""
'If you want to CC this email to someone else, uncomment the line below
'objMM.Cc = "someone@someaddress.com"
'If you want to BCC this email to someone else, uncomment the line below
'objMM.Bcc = "someone@someaddress.com"
'Send the email in text format
objMM.BodyFormat = MailFormat.Html
'(to send HTML format, change MailFormat.Text to MailFormat.Html)
'Set the priority - options are High, Low, and Normal
objMM.Priority = MailPriority.Normal
'Set the subject
objMM.Subject = "Hall Imports - Get A Quote"
'Set the body
objMM.Body = "CUSTOMER GET A QUOTE INFORMATION<br>" & _
"---------------------------------------------------<p>" & _
"This request is submitted at <strong>"+ DateTime.Now + "</strong><p>"& _
"Contact Information<br>" & _
"--------------------<br>" & _
"First Name : <strong>" + txtFirstName.Text + "</strong><br>" & _
"Last Name : <strong>" + txtLastName.Text + "</strong><br>" & _
"Address : <strong>" + txtAddress.Text + "</strong><br>" & _
"City : <strong>" + txtCity.Text + "</strong><br>" & _
"State : <strong>" + txtState.Text + "</strong><br>" & _
"Zip : <strong>" + txtZip.Text + "</strong><br>" & _
"E-mail : <strong>" + txtEmail.Text + "</strong><br>" & _
"Contact # : <strong>" + txtContact1.Text + "</strong><br>" & _
"Contact # : <strong>" + txtContact2.Text + "</strong><p>" & _
"Vehicle Information<br>" & _
"--------------------<br>" & _
"Vehicle type : <strong>" + request.form("radNewUsed") + "</strong><br>" & _
"Make : <strong>" + txtMake.Text + "</strong><br>" & _
"Year : <strong>" + txtYear.Text + "</strong><br>" & _
"Model : <strong>" + txtModel.Text + "</strong><p>" & _
"Desired Options<br>" & _
"-----------------<br><strong>" + txtOption.Text + "</strong><p>"
'Specify to use the default Smtp Server
'SmtpMail.SmtpServer = ""
SmtpMail.SmtpServer = "smtp-server.wi.rr.com"
'Now, to send the message, use the Send method of the SmtpMail class
SmtpMail.Send(objMM)
Response.Redirect("getaquotethank.html")
End Sub
</script>
<html><title>Hall Imports - Get a Quote</title>
<link href="/webroot/stylesheet.css" rel="stylesheet" type="text/css">
<body onLoad="window.focus();">
<asp:panel id="panelSendEmail" runat="server">
<table width="600" border="0" align="center" bordercolor="#000000" bgcolor="#FFFFFF">
<tr class="maincontent">
<td><p align="center"><img src="/webroot/Images/logo-hall.gif" width="259" height="63"></p>
<p><strong>Get A Quote</strong></p>
<p>Please complete the following fields and we will contact you shortly.<br>
<font color="#FF0000">*</font> Please note these fields that are marked
with an (*) are required to submit your quote. </p>
<form runat="server">
<table width="600" border="0" class="maincontent">
<tr>
<td colspan="4"><asp:RequiredFieldValidator ControlToValidate="txtFirstName" Text="The First name field is required!<br>" runat="server" Display="Dynamic"/>
<asp:RequiredFieldValidator ControlToValidate="txtLastName" Text="The Last name field is required!<br>" runat="server" Display="Dynamic"/>
<asp:RequiredFieldValidator ControlToValidate="txtContact1" Text="At Least One Contact # is required!<br>" runat="server" Display="Dynamic"/>
<asp:RequiredFieldValidator ControlToValidate="txtMake" Text="The Make field is required!<br>" runat="server" Display="Dynamic"/>
<asp:RequiredFieldValidator ControlToValidate="txtYear" Text="The Year field is required!<br>" runat="server" Display="Dynamic"/>
<asp:RequiredFieldValidator ControlToValidate="txtModel" Text="The Model field is required!<br>" runat="server" Display="Dynamic"/>
</td>
</tr>
<tr bgcolor="#000099">
<td colspan="4"><strong><font color="#FFFFFF">Contact Information</font></strong></td>
</tr>
<tr>
<td width="106">First Name :</td>
<td width="195"><asp:textbox id="txtFirstName" runat="server" />
<font color="#FF0000">*</font></td>
<td width="87">Last Name:</td>
<td width="194"><asp:textbox id="txtLastName" runat="server" />
<font color="#FF0000">*</font> </td>
</tr>
<tr>
<td>Address :</td>
<td><asp:textbox id="txtAddress" runat="server" /></td>
<td>State :</td>
<td><asp:textbox id="txtState" runat="server" /></td>
</tr>
<tr>
<td>City :</td>
<td><asp:textbox id="txtCity" runat="server" /></td>
<td>Zip :</td>
<td><asp:textbox id="txtZip" runat="server" /></td>
</tr>
<tr>
<td>Email :</td>
<td><asp:textbox id="txtEmail" runat="server" /></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Contact # :</td>
<td><asp:textbox id="txtContact1" runat="server" /> <font color="#FF0000">*</font>
</td>
<td>Contact # :</td>
<td><asp:textbox id="txtContact2" runat="server" /></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bgcolor="#000099">
<td colspan="4"><font color="#FFFFFF"><strong>Vehicle Information</strong></font></td>
</tr>
<tr>
<td>New Vehicle</td>
<td><input name="radNewUsed" type="radio" value="New" checked></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Used Vehicle</td>
<td><input type="radio" name="radNewUsed" value="Used"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Make : </td>
<td><asp:textbox id="txtMake" runat="server" /> <font color="#FF0000">*</font>
</td>
<td>Year :</td>
<td><asp:textbox id="txtYear" maxlength="4" runat="server" /> <font color="#FF0000">*</font>
</td>
</tr>
<tr>
<td>Model :</td>
<td><asp:textbox id="txtModel" runat="server" /> <font color="#FF0000">*</font>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bgcolor="#000099">
<td colspan="4"><strong><font color="#FFFFFF">Desired Options</font></strong></td>
</tr>
<tr>
<td colspan="4"><asp:textbox id="txtOption" TextMode="MultiLine" Columns="65" Rows="7" runat="server" /></td>
</tr>
<tr>
<td colspan="4">Once you have submitted your information, our specialist
will contact you shortly. </td>
</tr>
<tr>
<td colspan="4"> <div align="center">
<table width="100%" border="0">
<tr>
<td> <div align="center">
<asp:button runat="server" id="btnSubmit" Text="Submit Inquiry" OnClick="btnSubmit_Click" />
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td colspan="4"> </td>
</tr>
</table>
</form>
</td></tr></table>
</asp:panel>
</body>
</html>
Please help my bosses is all over my butt and I have no clue.
the new code that works is as follows:
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Web" %>
<%@ import Namespace="System.Web.Mail" %>
<script runat="server">
public Domainname as string = ""
'Modifying MailServer due to internal network changes. Should just be mail-fwd now.
'Public MailServer as string = ""
Public MailServer as string = "mail-fwd"
Public From as string = ""
public subject1 as string = " "
Sub Page_Load(sender As Object, e As EventArgs)
domain.text = "@" & Domainname
subj.text = Subject1
end sub
Sub Submit_Click(sender As Object, e As EventArgs)
dim fld as object
Try
Dim Mailer As MailMessage
Mailer = New MailMessage()
Mailer.From = From
Mailer.To = ""
Mailer.Subject = Subject1 & Subject.text
Mailer.Body = message.text
Mailer.BodyFormat = MailFormat.text 'MailFormat.Html
SmtpMail.SmtpServer = MailServer
SmtpMail.Send(Mailer)
label2.text ="Thank you very much for your submission, someone will contract you shortly"
label3.text = ""
Catch ex As Exception
' this will Display the error message and stack trace
label2.text = "Your message was not sent: " + ex.Message
label3.text = ex.tostring
End Try
End Sub
</script>
<html>
<head>
<title>Hall Chevrolet Information Request</title>
</head>
<body>
<p><img src="/Images/logo-hall.gif" width="259" height="63"><br />
</p>
<form runat="server">
<table style="WIDTH: 598px; HEIGHT: 174px" width="598" border="0">
<tbody>
<tr>
<td align="right"> </td>
<td> </td>
</tr>
<tr>
<td align="right" width="92">
Mail To:</td>
<td width="508">
<asp:Label id="Domain" runat="server" width="335px" font-bold="True">Label</asp:Label></td>
</tr>
<tr>
<td align="right" width="92">
<p>Subject:</p></td>
<td width="508">
<asp:TextBox ID="Subject" runat="server" Width="0px" ReadOnly="true"></asp:TextBox>
<asp:Label id="Subj" runat="server" width="137px" font-bold="True">Label</asp:Label>
<p>
<select name="Subject" id="Subject">
<option>General Information Request</option>
<option>New Car Quote</option>
<option>Used Car Quote</option>
<option>Trade Evaluation</option>
</select>
</p></td>
</tr>
<tr>
<td align="right" width="92">
Additional Information:</td>
<td width="508">
<asp:TextBox ID="Message" runat="server" Width="450px" Height="63px"></asp:TextBox>
<p> </p>
</td>
</tr>
<tr>
<td width="92">
</td>
<td width="408">
<asp:Button id="Submit" onclick="Submit_Click" runat="server" Text="Send Email"></asp:Button>
</td>
</tr>
</tbody>
</table>
</form>
<a href="/index.htm">Home</a><br />
<asp:Label id="Label2" runat="server" height="17px" backcolor="LightGoldenrodYellow"></asp:Label>
<br />
<asp:Label id="Label3" runat="server" backcolor="Honeydew"></asp:Label>
<br />
<br />
<br />
<br />
</body>
</html>