Click to See Complete Forum and Search --> : asp.net email form
PeOfEo
03-15-2003, 02:15 PM
I was making a form that would allow people to email everybody in my data base, or just one person. I useing a drop down list to select the member name and all. My problem is I had some strange compilation errors, So I want to completly redo it and make a regular email form, then do the data base stuff ( I need a separate feedback form anyway) Let me test this script that I have here now for an email form. I will post it in a little while
PeOfEo
03-15-2003, 02:34 PM
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30390: 'System.Web.Mail.SmtpMail.Private Overloads Sub New()' is not accessible in this context because it is 'Private'.
Source Error:
Line 26: Dim TheMessage as String
Line 27: Dim TheMailMessage as New MailMessage
Line 28: Dim TheMailConnection as New SmtpMail
Line 29: TheMessage = "Request for more information! " & chr(13) _
Line 30: & "Name: " & txtName.Text & chr(13) _
ok I get that error in both forms, stright out of my book (boy it sucks doesnt it, its like they never tested any of it)
Anyways what should I change that to? The smtpmail should be what? Ill post the complte code below
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<%@ Import Namespace="System.Web.Mail" %>
<script runat="server">
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
if Not IsPostBack Then
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("/knights/c3moreinfo.mdb;"))
DBCommand = New OleDbDataAdapter _
("Select MoreInfoCategory, MoreInfoEmailAddress " _
& "From MoreInfoCategories " _
& "Order By MoreInfoCategory", DBConn)
DBCommand.Fill(DSPageData, _
"Categories")
ddlTopics.DataSource = _
DSPageData.Tables("Categories").DefaultView
ddlTopics.DataBind()
End If
End Sub
Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
Dim TheMessage as String
Dim TheMailMessage as New MailMessage
Dim TheMailConnection as New SmtpMail
TheMessage = "Request for more information! " & chr(13) _
& "Name: " & txtName.Text & chr(13) _
& "Email Address: " & txtEmailAddress.Text & chr(13) _
& "More Info Category: " & ddlTopics.SelectedItem.Text _
& chr(13) _
& "Comment: " & txtComment.Text
TheMailMessage.From = txtEmailAddress.Text
TheMailMessage.To = ddlTopics.SelectedItem.Value
TheMailMessage.Subject = "Request for More Information"
TheMailMessage.Body = TheMessage
TheMailConnection.Send(TheMailMessage)
pnlRequest.Visible = False
lblMessage.Text = "Your message has been sent. " _
& "We will respond to your request as soon as possible."
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Request for More Information</TITLE>
</HEAD>
<BODY TEXT="black" LINK="darkblue" VLINK="darkblue" ALINK="red" LEFTMARGIN="40">
<form runat="server">
<asp:Label
id="lblTitle"
BorderWidth="7px"
BorderStyle=7
Width="90%"
Font-Size="25pt"
Font-Name="Arial"
Text="Request for More Information"
runat="server"
/>
<Font Face="Arial">
<BR><BR>
<asp:Label
id="lblMessage"
Font-Bold="True"
Text="Please select the topic of your request and
enter your personal information"
runat="server"
/>
<BR><BR>
<asp:Panel
id="pnlRequest"
Width="90%"
runat="server"
>
<Table>
<TR>
<TD>
Topic:
</TD>
<TD>
<asp:dropdownlist
id="ddlTopics"
runat="server"
DataTextField="MoreInfoCategory"
DataValueField="MoreInfoEmailAddress"
>
</asp:dropdownlist>
</TD>
</TR>
<TR>
<TD>
Your Name:
</TD>
<TD>
<asp:TextBox
id="txtName"
Columns="25"
MaxLength="100"
runat="server"
/>
</TD>
</TR>
<TR>
<TD>
Email Address:
</TD>
<TD>
<asp:TextBox
id="txtEmailAddress"
Columns="25"
MaxLength="100"
runat="server"
/>
<asp:RequiredFieldValidator
id="rfvEmailAddress"
ControlToValidate="txtEmailAddress"
Display="Dynamic"
Font-Name="Arial"
Font-Size="10pt"
runat="server"
errormessage="Email Address is Required!">
</asp:RequiredFieldValidator>
</TD>
</TR>
<TR>
<TD VAlign="Top">
Comment:
</TD>
<TD>
<asp:TextBox
id="txtComment"
Columns="40"
Rows="5"
runat="server"
TextMode="MultiLine"
/>
</TD>
</TR>
</Table>
<asp:button
id="butOK"
text=" OK "
Type="Submit"
OnClick="SubmitBtn_Click"
runat="server"
/>
</asp:Panel>
</Font>
</Form>
</BODY>
</HTML>
Ribeyed
03-15-2003, 06:42 PM
hi Nick,
never had time to run through your code to see the error the syntax you are using for sending email looks similar to that of ASP. Goos thing ASP.NET tidies up the process and makes it simple:
<Script runat="server">
Sub Button_click(s As Object, e As EventArges )
SmtpMail.Send( _
mailfrom.Text,_
mailto.Text, _
mailsubject.Text, _
mailbody.Text )
End Sub
</script>
Give that a try and let me know how you get on. :D
PeOfEo
03-15-2003, 07:42 PM
well it uses a data base, The drop down list displays the names in the data base, and well right now its on a separate data base with 2 names, but I will copy everything over once this works and put it on the main data base so everyone on the members list that I have been using before can email eachother.