Click to See Complete Forum and Search --> : smtp connection problems (asp.net)


PeOfEo
03-30-2003, 05:39 PM
ok this code



<%@ 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/emailer/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 BACKGROUND="./lightblue.gif" 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>

produces this error
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 what I am trying to do is make an email form that sends the mail to a person in the data base. I cant figure it out at all why it is going wrong. Could it be the web mail host I use or their smtp server?

PeOfEo
03-30-2003, 05:42 PM
ok as i looked at my code a say a few runat=servers, ill correct those but that doesnt seem to be whats causing this error as you can see.