Asp.net Errors on compiling & runtime, Could not load type 'EmailSubscribers' &

westdh
westdh used Ask the Experts™
on
Asp.net Errors on compiling & runtime, Could not load type 'EmailSubscribers' &  Mail ??

Run time error:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'EmailSubscribers'.

Source Error:


Line 1:  
Line 2:  <%@ Page language="VB" Debug="true" Inherits="EmailSubscribers" CodeBehind="EmailSubscribers.aspx.vb" AutoEventWireup="false" validateRequest="false" %>
Line 3:  
Line 4:  <html>
 



Complie errors
--------------------------------------------
Error      4      Could not load type 'EmailSubscribers'.      C:\WebSite2\Annonymous\EmailSubscribers.aspx      2      
Error      5      Overload resolution failed because no accessible 'New' accepts this number of arguments.      C:\WebSite2\Annonymous\EmailSubscribers.aspx.vb      77      25      C:\WebSite2\

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Drawing
Imports System.IO
Imports System.Net
Imports System.Web
Imports System.Net.Mail
Imports System.Web.SessionState
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Text

Public Class EmailSubscribers : Inherits System.Web.UI.Page
    Protected RtnHomeButton As System.Web.UI.WebControls.HyperLink
    Protected MyDataGrid As System.Web.UI.WebControls.DataGrid

    '*******************************************************
    '
    ' The Page_Load event handler on this User Control is used to
    ' obtain a DataReader of contact information from the Contacts
    ' table, and then databind the results to a DataGrid
    ' server control.  It uses the ASPNetPortal.ContactsDB()
    ' data component to encapsulate all data functionality.
    '
    '*******************************************************

    Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Not IsPostBack Then
            Dim myConnection As New SqlConnection("ASPNETDBConnectionString")
            Dim myCommand As New SqlCommand("SELECT emailID email FROM subscriptions", myConnection)

            myConnection.Open()

            Dim dr As SqlDataReader = myCommand.ExecuteReader()

            MyDataGrid.DataSource = dr
            MyDataGrid.DataBind()

            myConnection.Close()

        End If
    End Sub

    Private Sub GetSelections_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim rowCount As Integer = 0
        Dim gridSelections As New StringBuilder()

        'Loop through each DataGridItem, and determine which CheckBox controls
        'have been selected.
        For Each DemoGridItem As DataGridItem In MyDataGrid.Items

            '(TextBox)(e.Item.Cells[1].FindControl("edit_Address1"));
            Dim myCheckbox As CheckBox = DirectCast(DemoGridItem.Cells(0).FindControl("myCheckbox"), CheckBox)
            If myCheckbox.Checked = True Then
                rowCount += 1
                gridSelections.AppendFormat("The checkbox for {0} was selected<br>", MyDataGrid.DataKeys(DemoGridItem.ItemIndex).ToString())

                'Trace.Write("test:2" + MyDataGrid.DataKeys[DemoGridItem.ItemIndex].ToString());


                Dim myConnection1 As New SqlConnection("ASPNETDBConnectionString")
                Dim myCommand As New SqlCommand("select Email from Pilots Where PilotsID = '" + MyDataGrid.DataKeys(DemoGridItem.ItemIndex).ToString() + "'", myConnection1)

                myConnection1.Open()

                Dim drn As SqlDataReader = myCommand.ExecuteReader()
                drn.Read()
                Dim ToEmail As String = DirectCast(drn("Email"), [String])

                If ToEmail <> "" Then

                    Dim Email As New System.Net.Mail.MailMessage(ToEmail)
                    Email.Subject = "Used Vocational Trucks.com - Sale Notices"
                    Email.Body = "To Contact Us:<br>Used Vocational Trucks.com<br>PO Box 503145<br>White City, OR  97503  USA<br>541-690-4735<br>info@usedvocationaltrucks.com<br>www.usedvocationaltrucks.com"
                    Dim mailClient As New System.Net.Mail.SmtpClient()

                    'This object stores the authentication values
                    Dim basicAuthenticationInfo As New System.Net.NetworkCredential("info@usedvocationaltrucks.com", "xxxxxNeedDave's email Paswd")

                    'Put your own, or your ISPs, mail server name onthis next line
                    mailClient.Host = "info@usedvocationaltrucks.com"
                    mailClient.UseDefaultCredentials = False
                    mailClient.Credentials = basicAuthenticationInfo

                    mailClient.Send(Email)
                End If
                myConnection1.Close()
            End If
        Next

        Response.Redirect(Request.ApplicationPath)
    End Sub

End Class

--------------

<%@ Page language="VB" Debug="true" Inherits="EmailSubscribers" CodeBehind="EmailSubscribers.aspx.vb" AutoEventWireup="false" validateRequest="false" %>

<html>
<head>
<title>
   <p>E-Mail Subscribers Posted Sales</p>
</title>
</head>
<body>

	<table border="0" cellspacing="0" cellpadding="0" width="600">
		<tr>
			<td align="left"><b>Send Email to Subscribers</b>(check send mail box)</td>
			<td align="right"><asp:hyperlink id="RtnHomeButton" cssclass="printbutton" NavigateUrl="~/Annonymous/index.aspx"
					runat="server">Home</asp:hyperlink></td>
		</tr>
	</table>
	<form id="default" method="post" runat="server">

		<P><asp:button id="GetSelections" runat="server" Text="Send Email to Subscribers"></asp:button></P>
		<P><asp:label id="ResultsInfo" runat="server"></asp:label></P>
		<asp:datagrid id="MyDataGrid" runat="server" DataKeyField="Email">
			<Columns>
				<asp:TemplateColumn HeaderText="Selected">
					<ItemTemplate>
						<asp:CheckBox ID="myCheckbox" Checked="True" Runat="server" />
					</ItemTemplate>
				</asp:TemplateColumn>
			</Columns>
		</asp:datagrid></form>
</body>
</html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2013
Commented:
Guess you need :
CodeFile="EmailSubscribers.aspx.vb"

not
CodeBehind="EmailSubscribers.aspx.vb"

Author

Commented:
Thanks that did it for the first proble but not my other regards the "Mail"

 Dim Email As New System.Net.Mail.MailMessage(ToEmail)

Asp.net Errors on compiling & runtime, Could not load type 'EmailSubscribers' &  Mail ??

Overload resolution failed because no accessible 'New' accepts this number of arguments.

this was translated code from .cs file to a vb file.
Top Expert 2013
Commented:
oh i just missed your second question....
There is no MailMessage constructor that takes one argument..
Check this: http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.mailmessage.aspx
So you might try one of shown in above link.

e.g.
 Dim Email As New System.Net.Mail.MailMessage(ToEmail,"somefromaddress@something.com")

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial