Compiler Error Message: BC30390

KRlAZElY

New Member
I'm getting the following error message when I try to run my aspx page:<BR><BR>Compiler Error Message: BC30390: 'System.Web.Mail.SmtpMail.Private Overloads Sub New()' is not accessible in this context because it is 'Private'.<BR><BR>The code looks like: <BR><%@ Import NameSpace="System.Web.Mail.SMTPMail"%><BR><%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%><BR><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><BR><HTML><BR> <HEAD><BR> <title>WebForm1</title><BR> <meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0"><BR> <meta name="CODE_LANGUAGE" content="Visual Basic 7.0"><BR> <meta name="vs_defaultClientScript" content="JavaScript"><BR> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"><BR> </HEAD><BR> <body MS_POSITIONING="GridLayout"><BR> <script runat="server"><BR> Public Sub btnLogin_Click(ByVal sender as Object, ByVal e as System.Eventargs)<BR> Dim objSMTP as New System.Web.Mail.SmtpMail()<BR> objSMTP.Send(txtEmail.text, txtEmail.text, "Test SMTP Mail", "This is a test!")<BR> End sub<BR> <BR> </script><BR> <form id="Form1" method="post" runat="server"><BR> <TABLE id="Table1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" cellSpacing="1" cellPadding="1" width="300" border="1"><BR> <TR><BR> <TD>E-Mail Address</TD><BR> <TD><BR> <asp:TextBox id="txtEMail" runat="server"></asp:TextBox></TD><BR> </TR><BR> <TR><BR> <TD>Password</TD><BR> <TD><BR> <INPUT type="password"></TD><BR> </TR><BR> <TR><BR> <TD align="middle" colSpan="2"><BR> <INPUT id="btnLogin" type="button" value=http://aspmessageboard.com/archive/index.php/"Login"></TD><BR> </TR><BR> </TABLE><BR> </form><BR> </body><BR></HTML><BR>Do not create an instance of the mail object.<BR><BR>Delete the line where you declare objSMTP<BR>and then replace objSMTP.Send with SMTPMail.Send<BR><BR>TThanks, but that didn't work either. Now its saying I have to delcare SMTP...<BR>The message is: <BR>Compiler Error Message: BC30451: Name 'SMTPMail' is not declared.<BR><BR>I've changed the click event handler to look like: <BR><BR>Public Sub btnLogin_Click(ByVal sender as Object, ByVal e as System.Eventargs)<BR>'Dim objSMTP as New System.Web.Mail.SmtpMail()<BR>SMTPMail.Send(txtEmail.text, txtEmail.text, "Test SMTP Mail", "This is a test!")<BR>End sub <BR><BR>BTW. Why can I instantiate a new object as type SMTPMail?<BR>Thanks.I believe it is because the smtpMail class is static, therefore all instances of smptmail can use the same instance.<BR><BR>What you do need to create is the mailmessage object which is fed to smtpmail.<BR><BR>Here is some basic mail code that we use.<BR><BR>Imports System.Web.Mail<BR><BR>Public Sub SendEmail(eTo,eFrom,eSubject,eBody)<BR> Dim smtpMssg AS new MailMessage <BR> smtpMssg.From = eFrom<BR> smtpMssg.To = eTo<BR> smtpMssg.Subject = eSubject<BR> smtpMssg.BodyFormat = MailFormat.Text<BR> smtpMssg.Body = eBody<BR> SmtpMail.SmtpServer=ConfigurationSettings.AppSetti ngs("mailserver")<BR> SmtpMail.Send(smtpMssg)<BR>End Sub<BR><BR>T
 
Back
Top