locked
Error trying to send email: BC30638: Array bounds cannot appear in type specifiers. RRS feed

  • Question

  • User2028823583 posted

    This is the first time I've tried to send email, so I've got a sendemail.aspx page, but it's throwing this error...    My code is below the 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: BC30638: Array bounds cannot appear in type specifiers.

    Source Error:

    Line 9:          Dim message As MailMessage = New MailMessage()
    Line 10:         Try
    Line 11:         Dim fromAddress As NewMailAddress("foo@foo.com", "From Test")
    Line 12:             Dim toAddress As New MailAddress("foo@foo.com", "To Test")
    Line 13:             message.From = fromAddress

     

     

    <%@ Page Language="VB" %>

    <%@ Import Namespace="System.Net.Mail" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    Sub SendEmail(ByVal s As Object, ByVal e As EventArgs)

    Dim smtpClient As SmtpClient = New SmtpClient()

    Dim message As MailMessage = New MailMessage()

    Try

    Dim fromAddress As NewMailAddress("foo@foo.com", "From Test")Dim toAddress As New MailAddress("foo@foo.com", "To Test")

    message.From = fromAddress

    message.To.Add(toAddress)

    message.Subject = "Testing!"

    message.Body = "this is the body"

    smtpClient.Host = "x.x.x.x"

    smtpClient.Send(message)

     

    statusLabel.Text = "email sent"

    Catch ex As Exception

    statusLabel.Text = "Sorry"

    End Try

     

    End Sub

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

    <title>Untitled Page</title> </head>

    <body>

    <form id="form1" runat="server">

    <asp:Button ID="sendEmailButton" runat="server" Text ="SendEmail!" OnClick ="SendEmail" /><br />

    <asp:Label ID ="statusLabel" runat="server" />

    <div>

     

    </div>

    </form> </body>

    </html>

    Wednesday, April 23, 2008 4:37 PM

Answers

  • User1485238302 posted

    Dim fromAddress As NewMailAddress("foo@foo.com", "From Test")

    Is this a typo. There is no space between New and MailAddress.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 23, 2008 4:57 PM

All replies

  • User1485238302 posted

    Dim fromAddress As NewMailAddress("foo@foo.com", "From Test")

    Is this a typo. There is no space between New and MailAddress.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 23, 2008 4:57 PM
  • User2028823583 posted

    D'oh...  thank you bullpit.  :-)  Works great now. 

    Thursday, April 24, 2008 8:28 AM
  • User1485238302 posted

    [;)][Yes]

    Thursday, April 24, 2008 8:29 AM