Click to See Complete Forum and Search --> : emailing through a data base
PeOfEo
04-03-2003, 11:24 AM
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
04-03-2003, 11:26 AM
<%@ 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>
thats my source code
PeOfEo
04-05-2003, 01:45 AM
well what your doing would be setting it like a variable, i would have to say dim themailconnection as varient then the set themailconnection=newsmtpmail, I dono this is weird =(
Ribeyed
04-05-2003, 06:32 AM
hi,
the correct syntax for the line is this:
Dim objSmtpMail As New SmtpMail()
'then you can have something like this:
objSmtpMail.Send(txtTo.text, txtFrom.text, txtSubject.text, txtMessage.text)
objSmtpMail = Nothing
Ribeyed
04-05-2003, 08:24 AM
hi,
in previous versions of ASP, you were required to use Set when assigning an object to a variable. In ASP.NET you no longer use the Set statement when creating ASP.NET pages with Visual Basic.NET.
'old
<% Set DataConn = Server.CreateObject("ADODB.Connection")%>
'New
<% DataConn = Server.CreateObject("ADODB.Connection")%>
PeOfEo
04-05-2003, 05:14 PM
ok well ill try your code ribeyed and see what it does, um after this I need to figure out how to email everyone in the dat base at one time =) to make it so my users can email eachother and keep connected (yes I will impliment security so people cannot spam, I will just only allow one mail per session and if they attmept to get off and get on and do things like that then I can ban their aco**** =). Oh just a visual basic question real fast. I was working on my screen saver and i wanter binary code for the actual numbers it running to scroll accross the top but like I can say X = BIN(Y)
i can say x = oct for octal or x = hex for hexidecimle but I wanted base 2. You know of anyway to do this without righting all of the conversions into my code? LIke I know how to convirt by hand and all but I just dont want to right all that code to do it, Ill use hex because its still cool.
PeOfEo
04-07-2003, 11:21 AM
That wont really work though, I am using vb to make this.
PeOfEo
04-07-2003, 04:44 PM
UGH
Compiler Error Message: BC30390: 'System.Web.Mail.SmtpMail.Private Overloads Sub New()' is not accessible in this context because it is 'Private'
PeOfEo
04-08-2003, 05:20 PM
I figured out my email problems, I mean it still wont work but I know them now... I have a working form but now I am having web.config problems and whenever I go to change my web.config I get a bunch of errors and its makeing me insane.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="Customer">
<appSettings>
<add key="ConnStr" value="data source=(local);Connect Timeout=30;User ID=knights;Password=******;database=H_knights"/>
</appSettings>
<system.web>
<identity impersonate="true"/>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
<location path="Public">
<appSettings>
<add key="ConnStr" value="data source=(local);Connect Timeout=30;User ID=knights;Password=******;database=H_knights"/>
</appSettings>
<system.web>
<identity impersonate="false"/>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>
</configuration>
I posted about it on my host's forum but I dono maybe you can see an error in it. I just dont get the web.config because I mean if alter the default one even the slightest bit I get hundreds of horrible errors about oh custom error mode is on blah blah blah, WHEN CLEARLY THE DARNED ERROR MODE ISNT AHHHHHHHHHH