asp.net mail form

A

Andre

I'm trying to add a asp.net page which will act as a contact-me e-mail
form to keep our e-mail addresses hidden from page visitors.

I've created a combo/drop down box listing our various departments,
then added textboxes for the user to fill in their name, phone number,
e-mail address and message. At the bottom is a submit button.

When the submit button is clicked, I'd like to be able to validate the
imputs, then send an e-mail to the department which was selected in
the drop-down menu. Afterwards, I'd like to redirect to another page.

I tried adding my c# implementation code on the click event of the
submit button. When the page loads and I click the submit button,
nothing appears to be happening. I tried doing the same thing without
using a form at all, but I got a parser error that the drop-down box
had to be inside form tags and containg a code-behind. Am I missing
something simple here?

Thanks in advance,

Andre
 
A

Andre

I'm still struggling with trying to make this work, I'm posting my
code in hopes that someone will recognize the problem. The original
site was done with Dreamweaver MX, I'm much more familiar with VS .NET
so I included the original .ASP page into a VS project.

The frustrating part is that the code does not run when I click the
submit button.




private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Submit1.ServerClick += new
System.EventHandler(this.Submit1_ServerClick);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Submit1_ServerClick(object sender, System.EventArgs e)
{
string sAddress= "";
string sSubject = Subject.Value.ToString();
string sMessage = Message.Value.ToString();
string sIndex = Department.Value.ToString();
string sEmail = EMail.Value.ToString();
string sName = Name.Value.ToString();
string sPhoneNum = PhoneNum.Value.ToString();

switch (sIndex)
{
case "1":
sAddress = "(e-mail address removed)";
break;
case "2":
sAddress = "(e-mail address removed)";
break;
case "3":
sAddress = "(e-mail address removed)";
break;
case "4":
sAddress = "(e-mail address removed)";
break;
case "5":
sAddress = "(e-mail address removed)";
break;
case "6":
sAddress = "(e-mail address removed)";
break;
case "7":
sAddress = "(e-mail address removed)";
break;
default:
sAddress = "(e-mail address removed)";
break;
}
MailMessage email = new MailMessage();
email.BodyFormat = MailFormat.Html;
email.Priority = MailPriority.High;
email.From = sEmail;
email.To = "(e-mail address removed)";
email.Subject = sSubject;
email.Body = "Name: " + sName + "<p>" +
"Phone: " + sPhoneNum + "<p>" +
"EMail: " + sEmail + "<p>" +
"Message: " + sMessage;
SmtpMail.SmtpServer = "192.168.1.22";
SmtpMail.Send(email);
lblStatus.Text = sIndex = " " + sAddress + " " + sSubject + " " +
sName;
 
A

Andre

<%@ Page LANGUAGE="c#" CODEPAGE="1252"
CodeBehind="form-contact.aspx.cs" AutoEventWireup="false"
Inherits="Form_Contact.form_contact" %>
<HTML>
<HEAD>
..
..
..
..
..
..

<form name="form1" method="post" action="">
<div align="left">
<p><font size="-1" face="Arial, Helvetica,
sans-serif">Department:</font><br>
<select name="select" id="Department" runat="server">
<option value="5">Accounts Receivable</option>
<option value="7" selected>Customer Service</option>
<option value="6">Human Resources</option>
<option value="4">Marketing/Sales</option>
<option value="2">Operations</option>
<option value="3">Pest Control</option>
<option value="1">President</option>
</select>
<br>
<font size="-1" face="Arial, Helvetica,
sans-serif">Name:<br>
<input name="Name" type="text" id="Name" size="50"
runat="server">
<br>
Phone Number:<br>
<input name="PhoneNum" type="text" id="PhoneNum" size="50"
runat="server">
<br>
E-Mail Address: </font>
<br>
<input name="EMail" type="text" id="EMail" size="50"
runat="server">
<br>
<font size="-1" face="Arial, Helvetica,
sans-serif">Subject:</font><br>
<input name="Subject" type="text" id="Subject" size="50"
runat="server">
<br>
<font size="-1" face="Arial, Helvetica,
sans-serif">Message:</font><br>
<textarea name="textfield" cols="50" rows="8" id="Message"
runat="server"></textarea>
</p>
<p align="center">
<input type="submit" name="Submit" value="Submit"
id="Submit1" runat="server">
<br>
</p>
</div>
</form>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,126
Latest member
FastBurnketoIngredients
Top